@base44-preview/cli 0.1.16-pr.626.cb8fa0d → 0.1.16-pr.626.e28b7e8

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
@@ -228657,6 +228657,20 @@ function isCLIError(error) {
228657
228657
  function isUserError(error) {
228658
228658
  return error instanceof UserError;
228659
228659
  }
228660
+ var STEP = Symbol.for("base44.commandStep");
228661
+ async function tagStep(step, run) {
228662
+ try {
228663
+ return await run();
228664
+ } catch (error) {
228665
+ if (error !== null && typeof error === "object" && !(STEP in error) && Object.isExtensible(error)) {
228666
+ Object.defineProperty(error, STEP, { value: step, enumerable: false });
228667
+ }
228668
+ throw error;
228669
+ }
228670
+ }
228671
+ function stepOf(error) {
228672
+ return error !== null && typeof error === "object" && STEP in error ? error[STEP] : undefined;
228673
+ }
228660
228674
 
228661
228675
  // src/core/utils/fs.ts
228662
228676
  async function pathExists(path) {
@@ -246795,6 +246809,49 @@ async function deployAll(projectData, options) {
246795
246809
  }
246796
246810
  return { connectorResults };
246797
246811
  }
246812
+ // src/core/project/target.ts
246813
+ import { dirname as dirname13, join as join19, resolve as resolve6 } from "node:path";
246814
+ var DEFAULT_BUILD_COMMAND = "npm run build";
246815
+ var DEFAULT_OUTPUT_DIRECTORY = "dist";
246816
+ async function resolveBuildTarget(projectRoot, overrides = {}) {
246817
+ const project = await readSettingsIfPresent(projectRoot);
246818
+ const root = project?.root ?? projectRoot ?? process.cwd();
246819
+ return {
246820
+ root,
246821
+ configDir: project ? dirname13(project.configPath) : join19(root, PROJECT_SUBDIR),
246822
+ buildCommand: project ? project.site?.buildCommand : DEFAULT_BUILD_COMMAND,
246823
+ outputDir: outputDirectory(project, root, overrides.outputDir),
246824
+ entitiesDir: project?.entitiesDir ?? "entities",
246825
+ agentsDir: project?.agentsDir ?? "agents"
246826
+ };
246827
+ }
246828
+ function outputDirectory(project, root, override) {
246829
+ const configured = override ?? (project ? project.site?.outputDirectory : DEFAULT_OUTPUT_DIRECTORY);
246830
+ return configured ? resolve6(root, configured) : null;
246831
+ }
246832
+ function requireOutputDir(target) {
246833
+ if (target.outputDir === null) {
246834
+ throw new ConfigNotFoundError("No site configuration found.", {
246835
+ hints: [
246836
+ {
246837
+ message: `Add 'site.outputDirectory' to your config.jsonc (e.g., "site": { "outputDirectory": "dist" })`
246838
+ },
246839
+ { message: `Or pass --output-dir <dir>, relative to ${target.root}` }
246840
+ ]
246841
+ });
246842
+ }
246843
+ return target.outputDir;
246844
+ }
246845
+ async function readSettingsIfPresent(projectRoot) {
246846
+ try {
246847
+ return await readProjectSettings(projectRoot);
246848
+ } catch (error) {
246849
+ if (error instanceof ConfigNotFoundError) {
246850
+ return null;
246851
+ }
246852
+ throw error;
246853
+ }
246854
+ }
246798
246855
  // src/core/clients/base44-client.ts
246799
246856
  var retriedRequests = new WeakSet;
246800
246857
  async function captureRequestBody(request, options) {
@@ -247248,169 +247305,6 @@ async function resolveBranchName(name) {
247248
247305
  return matches[0].id;
247249
247306
  }
247250
247307
 
247251
- // src/core/version/publish.ts
247252
- import { randomUUID as randomUUID4 } from "node:crypto";
247253
-
247254
- // src/core/version/schema.ts
247255
- var DeclareVersionResponseSchema = object({
247256
- session_id: string2(),
247257
- uploads: array(object({
247258
- path: string2(),
247259
- url: string2(),
247260
- content_type: string2(),
247261
- content_length: number2(),
247262
- checksum_sha256: string2()
247263
- }))
247264
- }).transform((data) => ({
247265
- sessionId: data.session_id,
247266
- uploads: data.uploads.map((upload) => ({
247267
- path: upload.path,
247268
- url: upload.url,
247269
- contentType: upload.content_type,
247270
- contentLength: upload.content_length,
247271
- checksumSha256: upload.checksum_sha256
247272
- }))
247273
- }));
247274
- var CreateVersionResponseSchema = object({
247275
- version_id: string2(),
247276
- manifest_hash: string2()
247277
- }).transform((data) => ({
247278
- versionId: data.version_id,
247279
- manifestHash: data.manifest_hash
247280
- }));
247281
- var EnvironmentResponseSchema = object({
247282
- name: string2(),
247283
- version_id: string2(),
247284
- manifest_hash: string2(),
247285
- deployment_id: string2()
247286
- }).transform((data) => ({
247287
- name: data.name,
247288
- versionId: data.version_id,
247289
- manifestHash: data.manifest_hash,
247290
- deploymentId: data.deployment_id
247291
- }));
247292
-
247293
- // src/core/version/api.ts
247294
- var DEFAULT_VERSION_UPLOAD_CONCURRENCY = 8;
247295
- var MAX_VERSION_UPLOAD_CONCURRENCY = 16;
247296
- function declaredFile({ path, size, digest }) {
247297
- return { path, size, digest };
247298
- }
247299
- function declaredModule(module) {
247300
- return { ...declaredFile(module), type: module.type };
247301
- }
247302
- function declaredAssetsConfig(config) {
247303
- const stated = {
247304
- html_handling: config?.htmlHandling ?? null,
247305
- not_found_handling: config?.notFoundHandling ?? null,
247306
- run_worker_first: config?.runWorkerFirst ?? null,
247307
- headers: config?.headers ?? null,
247308
- redirects: config?.redirects ?? null
247309
- };
247310
- return Object.values(stated).every((v) => v === null) ? null : stated;
247311
- }
247312
- async function post(path, json, doing) {
247313
- try {
247314
- return await getAppClient().post(path, { json, timeout: 180000 });
247315
- } catch (error) {
247316
- throw await ApiError.fromHttpError(error, doing);
247317
- }
247318
- }
247319
- async function patch(path, json, doing) {
247320
- try {
247321
- return await getAppClient().patch(path, { json, timeout: 180000 });
247322
- } catch (error) {
247323
- throw await ApiError.fromHttpError(error, doing);
247324
- }
247325
- }
247326
- function parse10(schema, body, what) {
247327
- const result = schema.safeParse(body);
247328
- if (!result.success) {
247329
- throw new SchemaValidationError(`Invalid ${what} response from server`, result.error);
247330
- }
247331
- return result.data;
247332
- }
247333
- async function createVersion(artifacts, options = {}) {
247334
- const declared = parse10(DeclareVersionResponseSchema, await (await post("versions", {
247335
- static_bundle: artifacts.files.map(declaredFile),
247336
- ...artifacts.siteWorker ? {
247337
- site_worker: {
247338
- main: artifacts.siteWorker.main,
247339
- modules: artifacts.siteWorker.modules.map(declaredModule),
247340
- assets: artifacts.siteWorker.assets.map(declaredFile),
247341
- compatibility_date: artifacts.siteWorker.compatibilityDate,
247342
- compatibility_flags: artifacts.siteWorker.compatibilityFlags,
247343
- assets_config: declaredAssetsConfig(artifacts.siteWorker.assetsConfig)
247344
- }
247345
- } : {},
247346
- entities: artifacts.entities,
247347
- agents: artifacts.agents,
247348
- source_commit: options.sourceCommit
247349
- }, "declaring a version")).json(), "declare");
247350
- const declaredFiles = [
247351
- ...artifacts.files,
247352
- ...artifacts.siteWorker?.modules ?? [],
247353
- ...artifacts.siteWorker?.assets ?? []
247354
- ];
247355
- options.progress?.onDeclared?.({ fileCount: declaredFiles.length });
247356
- if (declared.uploads.length !== declaredFiles.length) {
247357
- throw new InternalError(`Declared ${declaredFiles.length} files but the server signed ${declared.uploads.length} upload URLs.`);
247358
- }
247359
- const drifted = declared.uploads.findIndex((upload, index) => upload.path !== declaredFiles[index].path);
247360
- if (drifted !== -1) {
247361
- throw new InternalError(`Upload ${drifted} is signed for ${declared.uploads[drifted].path}, but that slot declared ${declaredFiles[drifted].path}.`);
247362
- }
247363
- let uploadedFiles = 0;
247364
- await pMap(declared.uploads, async (upload, index) => {
247365
- await putPresigned(upload, declaredFiles[index].absolutePath);
247366
- uploadedFiles++;
247367
- options.progress?.onUpload?.({
247368
- uploadedFiles,
247369
- totalFiles: declared.uploads.length
247370
- });
247371
- }, { concurrency: options.concurrency ?? DEFAULT_VERSION_UPLOAD_CONCURRENCY });
247372
- return parse10(CreateVersionResponseSchema, await (await post(`versions/${encodeURIComponent(declared.sessionId)}/finalize`, {}, "creating a version")).json(), "create version");
247373
- }
247374
- async function setEnvironmentVersion(environment, versionId, options = {}) {
247375
- return parse10(EnvironmentResponseSchema, await (await patch(`environments/${encodeURIComponent(environment)}`, {
247376
- version_id: versionId,
247377
- ...options.idempotencyKey ? { idempotency_key: options.idempotencyKey } : {}
247378
- }, "setting the environment's version")).json(), "environment");
247379
- }
247380
-
247381
- // src/core/version/publish.ts
247382
- var STEP = Symbol.for("base44.publishStep");
247383
- var DEFAULT_ENVIRONMENT = "production";
247384
- async function tagStep(step, run) {
247385
- try {
247386
- return await run();
247387
- } catch (error) {
247388
- if (error !== null && typeof error === "object" && !(STEP in error) && Object.isExtensible(error)) {
247389
- Object.defineProperty(error, STEP, { value: step, enumerable: false });
247390
- }
247391
- throw error;
247392
- }
247393
- }
247394
- function stepOf(error) {
247395
- return error !== null && typeof error === "object" && STEP in error ? error[STEP] : undefined;
247396
- }
247397
- async function publishVersion(artifacts, options = {}) {
247398
- const version = await tagStep("create_version", () => createVersion(artifacts, {
247399
- sourceCommit: options.sourceCommit,
247400
- concurrency: options.concurrency,
247401
- progress: options.progress
247402
- }));
247403
- const environment = await tagStep("deploy", () => setEnvironmentVersion(options.target ?? DEFAULT_ENVIRONMENT, version.versionId, {
247404
- idempotencyKey: randomUUID4()
247405
- }));
247406
- return {
247407
- environment: environment.name,
247408
- versionId: environment.versionId,
247409
- manifestHash: environment.manifestHash,
247410
- deploymentId: environment.deploymentId
247411
- };
247412
- }
247413
-
247414
247308
  // src/cli/utils/command/Base44Command.ts
247415
247309
  function writeJsonSuccess(result) {
247416
247310
  if (result.stdout) {
@@ -247801,7 +247695,7 @@ function getActorsCommand() {
247801
247695
  }
247802
247696
 
247803
247697
  // src/cli/commands/agent-skills/pull.ts
247804
- import { dirname as dirname13, join as join19 } from "node:path";
247698
+ import { dirname as dirname14, join as join20 } from "node:path";
247805
247699
  // src/core/utils/dependencies.ts
247806
247700
  import { spawnSync as spawnSync2 } from "node:child_process";
247807
247701
  function verifyDenoInstalled(context) {
@@ -247890,7 +247784,7 @@ async function pullAction({
247890
247784
  runTask
247891
247785
  }) {
247892
247786
  const { project } = await readProjectConfig();
247893
- const dir = join19(dirname13(project.configPath), project.agentSkillsDir);
247787
+ const dir = join20(dirname14(project.configPath), project.agentSkillsDir);
247894
247788
  const remote = await runTask("Fetching agent skills from Base44", () => fetchAgentSkills(), {
247895
247789
  successMessage: "Agent skills fetched successfully",
247896
247790
  errorMessage: "Failed to fetch agent skills"
@@ -247946,14 +247840,14 @@ function getAgentSkillsCommand() {
247946
247840
  }
247947
247841
 
247948
247842
  // src/cli/commands/agents/pull.ts
247949
- import { dirname as dirname14, join as join20 } from "node:path";
247843
+ import { dirname as dirname15, join as join21 } from "node:path";
247950
247844
  async function pullAgentsAction({
247951
247845
  log,
247952
247846
  runTask
247953
247847
  }) {
247954
247848
  const { project } = await readProjectConfig();
247955
- const configDir = dirname14(project.configPath);
247956
- const agentsDir = join20(configDir, project.agentsDir);
247849
+ const configDir = dirname15(project.configPath);
247850
+ const agentsDir = join21(configDir, project.agentsDir);
247957
247851
  const remoteAgents = await runTask("Fetching agents from Base44", async () => {
247958
247852
  return await fetchAgents();
247959
247853
  }, {
@@ -248023,12 +247917,12 @@ function getAgentsCommand() {
248023
247917
  }
248024
247918
 
248025
247919
  // src/cli/commands/auth/password-login.ts
248026
- import { dirname as dirname15, join as join21 } from "node:path";
247920
+ import { dirname as dirname16, join as join22 } from "node:path";
248027
247921
  async function passwordLoginAction({ log, runTask }, action) {
248028
247922
  const shouldEnable = action === "enable";
248029
247923
  const { project } = await readProjectConfig();
248030
- const configDir = dirname15(project.configPath);
248031
- const authDir = join21(configDir, project.authDir);
247924
+ const configDir = dirname16(project.configPath);
247925
+ const authDir = join22(configDir, project.authDir);
248032
247926
  const updated = await runTask("Updating local auth config", async () => {
248033
247927
  const current = await readAuthConfig(authDir) ?? DEFAULT_AUTH_CONFIG;
248034
247928
  const merged = { ...current, enableUsernamePassword: shouldEnable };
@@ -248048,14 +247942,14 @@ function getPasswordLoginCommand() {
248048
247942
  }
248049
247943
 
248050
247944
  // src/cli/commands/auth/pull.ts
248051
- import { dirname as dirname16, join as join22 } from "node:path";
247945
+ import { dirname as dirname17, join as join23 } from "node:path";
248052
247946
  async function pullAuthAction({
248053
247947
  log,
248054
247948
  runTask
248055
247949
  }) {
248056
247950
  const { project } = await readProjectConfig();
248057
- const configDir = dirname16(project.configPath);
248058
- const authDir = join22(configDir, project.authDir);
247951
+ const configDir = dirname17(project.configPath);
247952
+ const authDir = join23(configDir, project.authDir);
248059
247953
  const remoteConfig = await runTask("Fetching auth config from Base44", async () => {
248060
247954
  return await pullAuthConfig();
248061
247955
  }, {
@@ -248119,7 +248013,7 @@ function getAuthPushCommand() {
248119
248013
  }
248120
248014
 
248121
248015
  // src/cli/commands/auth/social-login.ts
248122
- import { dirname as dirname17, join as join23, resolve as resolve6 } from "node:path";
248016
+ import { dirname as dirname18, join as join24, resolve as resolve7 } from "node:path";
248123
248017
  var PROVIDER_LABELS = {
248124
248018
  google: "Google",
248125
248019
  microsoft: "Microsoft",
@@ -248159,7 +248053,7 @@ async function socialLoginAction({ log, isNonInteractive, runTask }, provider, a
248159
248053
  let clientSecret;
248160
248054
  if (useCustomOAuth && oauth && oauthCli && hasSecretOptions(options)) {
248161
248055
  if (options.envFile) {
248162
- const secrets = await parseEnvFile(resolve6(options.envFile));
248056
+ const secrets = await parseEnvFile(resolve7(options.envFile));
248163
248057
  const value = secrets[oauthCli.envVar];
248164
248058
  if (!value) {
248165
248059
  throw new InvalidInputError(`Key "${oauthCli.envVar}" not found in ${options.envFile}.`);
@@ -248189,8 +248083,8 @@ async function socialLoginAction({ log, isNonInteractive, runTask }, provider, a
248189
248083
  }
248190
248084
  }
248191
248085
  const { project } = await readProjectConfig();
248192
- const configDir = dirname17(project.configPath);
248193
- const authDir = join23(configDir, project.authDir);
248086
+ const configDir = dirname18(project.configPath);
248087
+ const authDir = join24(configDir, project.authDir);
248194
248088
  const { config: updated } = await runTask("Updating local auth config", async () => updateSocialLoginConfig(authDir, provider, shouldEnable, useCustomOAuth && options.clientId ? { clientId: options.clientId } : undefined));
248195
248089
  if (clientSecret) {
248196
248090
  await runTask("Saving client secret", async () => pushCustomOAuthSecret(provider, clientSecret));
@@ -248215,7 +248109,7 @@ function getSocialLoginCommand() {
248215
248109
  }
248216
248110
 
248217
248111
  // src/cli/commands/auth/sso.ts
248218
- import { dirname as dirname18, join as join24, resolve as resolve7 } from "node:path";
248112
+ import { dirname as dirname19, join as join25, resolve as resolve8 } from "node:path";
248219
248113
  var SSOConfigFileSchema = object({
248220
248114
  provider: _enum(Object.values(KNOWN_SSO_PROVIDERS)),
248221
248115
  clientId: string2(),
@@ -248231,7 +248125,7 @@ var SSOConfigFileSchema = object({
248231
248125
  ssoName: string2().optional()
248232
248126
  });
248233
248127
  async function loadSSOConfigFile(filePath) {
248234
- const resolved = resolve7(filePath);
248128
+ const resolved = resolve8(filePath);
248235
248129
  const raw = await readJsonFile(resolved);
248236
248130
  const result = SSOConfigFileSchema.safeParse(raw);
248237
248131
  if (!result.success) {
@@ -248319,7 +248213,7 @@ async function ssoEnableAction({ isNonInteractive, runTask }, options) {
248319
248213
  }
248320
248214
  let clientSecret;
248321
248215
  if (merged.envFile && !merged.clientSecret) {
248322
- const secrets = await parseEnvFile(resolve7(merged.envFile));
248216
+ const secrets = await parseEnvFile(resolve8(merged.envFile));
248323
248217
  const value = secrets.sso_client_secret;
248324
248218
  if (!value) {
248325
248219
  throw new InvalidInputError(`Key "sso_client_secret" not found in ${merged.envFile}.`);
@@ -248378,8 +248272,8 @@ async function ssoEnableAction({ isNonInteractive, runTask }, options) {
248378
248272
  throw error;
248379
248273
  }
248380
248274
  const { project } = await readProjectConfig();
248381
- const configDir = dirname18(project.configPath);
248382
- const authDir = join24(configDir, project.authDir);
248275
+ const configDir = dirname19(project.configPath);
248276
+ const authDir = join25(configDir, project.authDir);
248383
248277
  await runTask("Updating local auth config", async () => updateSSOConfig(authDir, provider, true));
248384
248278
  await runTask("Saving SSO credentials", async () => pushSSOSecrets(secrets));
248385
248279
  return {
@@ -248394,8 +248288,8 @@ async function ssoDisableAction({ log, runTask }, options) {
248394
248288
  throw new InvalidInputError("Configuration options cannot be used with disable. To disable SSO: base44 auth sso disable");
248395
248289
  }
248396
248290
  const { project } = await readProjectConfig();
248397
- const configDir = dirname18(project.configPath);
248398
- const authDir = join24(configDir, project.authDir);
248291
+ const configDir = dirname19(project.configPath);
248292
+ const authDir = join25(configDir, project.authDir);
248399
248293
  const updated = await runTask("Updating local auth config", async () => updateSSOConfig(authDir, null, false));
248400
248294
  await runTask("Removing SSO credentials", async () => deleteSSOSecrets());
248401
248295
  if (!hasAnyLoginMethod(updated)) {
@@ -249277,13 +249171,13 @@ function getConnectorsListAvailableCommand() {
249277
249171
  }
249278
249172
 
249279
249173
  // src/cli/commands/connectors/pull.ts
249280
- import { dirname as dirname19, join as join25, resolve as resolve8 } from "node:path";
249174
+ import { dirname as dirname20, join as join26, resolve as resolve9 } from "node:path";
249281
249175
  async function resolveConnectorsDir(options) {
249282
249176
  if (!getAppContext().projectRoot) {
249283
- return resolve8(options.dir ?? "connectors");
249177
+ return resolve9(options.dir ?? "connectors");
249284
249178
  }
249285
249179
  const { project } = await readProjectConfig();
249286
- return join25(dirname19(project.configPath), project.connectorsDir);
249180
+ return join26(dirname20(project.configPath), project.connectorsDir);
249287
249181
  }
249288
249182
  async function pullConnectorsAction({ log, runTask, jsonMode }, options) {
249289
249183
  const connectorsDir = await resolveConnectorsDir(options);
@@ -249324,10 +249218,10 @@ function getConnectorsPullCommand() {
249324
249218
  }
249325
249219
 
249326
249220
  // src/cli/commands/connectors/push.ts
249327
- import { resolve as resolve9 } from "node:path";
249221
+ import { resolve as resolve10 } from "node:path";
249328
249222
  async function readConnectorsToPush(options) {
249329
249223
  if (!getAppContext().projectRoot) {
249330
- return readAllConnectors(resolve9(options.dir ?? "connectors"));
249224
+ return readAllConnectors(resolve10(options.dir ?? "connectors"));
249331
249225
  }
249332
249226
  const { connectors } = await readProjectConfig();
249333
249227
  return connectors;
@@ -249670,11 +249564,11 @@ function getListCommand() {
249670
249564
  }
249671
249565
 
249672
249566
  // src/cli/commands/functions/pull.ts
249673
- import { dirname as dirname20, join as join26 } from "node:path";
249567
+ import { dirname as dirname21, join as join27 } from "node:path";
249674
249568
  async function pullFunctionsAction({ log, runTask }, name) {
249675
249569
  const { project, functions } = await readProjectConfig();
249676
- const configDir = dirname20(project.configPath);
249677
- const functionsDir = join26(configDir, project.functionsDir);
249570
+ const configDir = dirname21(project.configPath);
249571
+ const functionsDir = join27(configDir, project.functionsDir);
249678
249572
  const pluginFunctionNames = new Set(functions.filter((fn) => fn.source.type === "plugin").map((fn) => fn.name));
249679
249573
  const remoteFunctions = await runTask("Fetching functions from Base44", async () => {
249680
249574
  const { functions } = await listDeployedFunctions();
@@ -249774,153 +249668,18 @@ async function maybeAskToBuild(isNonInteractive, buildCommand) {
249774
249668
  });
249775
249669
  return !Ct(answer) && answer;
249776
249670
  }
249777
- // src/core/version/artifacts.ts
249778
- import { createHash as createHash2 } from "node:crypto";
249779
- import { join as join28, resolve as resolve11 } from "node:path";
249780
249671
 
249781
- // src/core/version/project.ts
249782
- import { dirname as dirname21, join as join27, resolve as resolve10 } from "node:path";
249783
- var DEFAULT_BUILD_COMMAND = "npm run build";
249784
- var DEFAULT_OUTPUT_DIRECTORY = "dist";
249785
- async function resolvePublishTarget(projectRoot, overrides = {}) {
249786
- const project = await readSettingsIfPresent(projectRoot);
249787
- const root = project?.root ?? projectRoot ?? process.cwd();
249672
+ // src/cli/commands/project/build.ts
249673
+ async function buildAction(ctx) {
249674
+ const app = requireApp(ctx);
249675
+ const target = await resolveBuildTarget(app.projectRoot);
249676
+ await runSiteBuild(ctx, {
249677
+ root: target.root,
249678
+ buildCommand: target.buildCommand,
249679
+ appId: app.id
249680
+ });
249788
249681
  return {
249789
- root,
249790
- configDir: project ? dirname21(project.configPath) : join27(root, PROJECT_SUBDIR),
249791
- buildCommand: project ? project.site?.buildCommand : DEFAULT_BUILD_COMMAND,
249792
- outputDir: outputDirectory(project, root, overrides.outputDir),
249793
- entitiesDir: project?.entitiesDir ?? "entities",
249794
- agentsDir: project?.agentsDir ?? "agents"
249795
- };
249796
- }
249797
- function outputDirectory(project, root, override) {
249798
- const configured = override ?? (project ? project.site?.outputDirectory : DEFAULT_OUTPUT_DIRECTORY);
249799
- return configured ? resolve10(root, configured) : null;
249800
- }
249801
- function requireOutputDir(target) {
249802
- if (target.outputDir === null) {
249803
- throw new ConfigNotFoundError("No site configuration found.", {
249804
- hints: [
249805
- {
249806
- message: `Add 'site.outputDirectory' to your config.jsonc (e.g., "site": { "outputDirectory": "dist" })`
249807
- },
249808
- { message: `Or pass --output-dir <dir>, relative to ${target.root}` }
249809
- ]
249810
- });
249811
- }
249812
- return target.outputDir;
249813
- }
249814
- async function readSettingsIfPresent(projectRoot) {
249815
- try {
249816
- return await readProjectSettings(projectRoot);
249817
- } catch (error) {
249818
- if (error instanceof ConfigNotFoundError) {
249819
- return null;
249820
- }
249821
- throw error;
249822
- }
249823
- }
249824
-
249825
- // src/core/version/artifacts.ts
249826
- var MAX_FILE_COUNT = 50000;
249827
- var HASH_CONCURRENCY = 32;
249828
- var ENTRY2 = "index.html";
249829
- async function digestFile(absolutePath) {
249830
- const hash = await hashFileInto(createHash2("sha256"), absolutePath);
249831
- return `sha256:${hash.digest("hex")}`;
249832
- }
249833
- async function collectBuildOutput(outputDir, options = {}) {
249834
- const found = await describeBuildOutput(outputDir);
249835
- if (found.length === 0) {
249836
- throw new InvalidInputError(`No files found in ${outputDir}. Build the site before creating a version.`, {
249837
- hints: [
249838
- { message: "Run 'base44 build' first", command: "base44 build" }
249839
- ]
249840
- });
249841
- }
249842
- if (found.length > MAX_FILE_COUNT) {
249843
- throw new InvalidInputError(`Too many files: found ${found.length}, the limit is ${MAX_FILE_COUNT}.`);
249844
- }
249845
- if (options.requireEntry !== false && !found.some((f) => f.path === ENTRY2)) {
249846
- throw new InvalidInputError(`${outputDir} has no ${ENTRY2}, so nothing could enter the site.`);
249847
- }
249848
- return await pMap(found, async (file) => ({ ...file, digest: await digestFile(file.absolutePath) }), { concurrency: HASH_CONCURRENCY });
249849
- }
249850
- async function collectSiteWorker(projectRoot) {
249851
- const built = await resolveFullStackBuild(projectRoot);
249852
- if (!built) {
249853
- return null;
249854
- }
249855
- const { config, modules, assetsDir } = built;
249856
- const entry = resolve11(config.configDir, config.main);
249857
- const main = modules.find((m) => m.absolutePath === entry)?.name;
249858
- if (!main) {
249859
- throw new InvalidInputError(`The Worker's entry module ${config.main} is not among the ${modules.length} modules collected from ${config.configDir}.`);
249860
- }
249861
- return {
249862
- main,
249863
- modules: await pMap(modules, async ({ name, absolutePath, size, type }) => ({
249864
- path: name,
249865
- absolutePath,
249866
- size,
249867
- digest: await digestFile(absolutePath),
249868
- type
249869
- }), { concurrency: HASH_CONCURRENCY }),
249870
- assets: assetsDir ? await collectBuildOutput(assetsDir, { requireEntry: false }) : [],
249871
- compatibilityDate: config.compatibilityDate,
249872
- compatibilityFlags: config.compatibilityFlags,
249873
- assetsConfig: config.assetsConfig
249874
- };
249875
- }
249876
- async function readRawResources(dir) {
249877
- if (!await pathExists(dir)) {
249878
- return {};
249879
- }
249880
- const files = await globby(`**/*.${CONFIG_FILE_EXTENSION_GLOB}`, {
249881
- cwd: dir,
249882
- onlyFiles: true,
249883
- followSymbolicLinks: false
249884
- });
249885
- const payloads = {};
249886
- for (const relativePath of files.sort()) {
249887
- const name = relativePath.replace(/\.jsonc?$/, "");
249888
- payloads[name] = await readJsonFile(join28(dir, ...relativePath.split("/")));
249889
- }
249890
- return payloads;
249891
- }
249892
- async function collectResources(configDir, dirs) {
249893
- const [entities, agents] = await Promise.all([
249894
- readRawResources(join28(configDir, dirs.entitiesDir)),
249895
- readRawResources(join28(configDir, dirs.agentsDir))
249896
- ]);
249897
- return { entities, agents };
249898
- }
249899
- async function collectArtifacts(target) {
249900
- const siteWorker = await collectSiteWorker(target.root);
249901
- return {
249902
- files: siteWorker ? [] : await collectBuildOutput(requireOutputDir(target)),
249903
- ...siteWorker ? { siteWorker } : {},
249904
- ...await collectResources(target.configDir, target)
249905
- };
249906
- }
249907
- // src/core/version/gate.ts
249908
- var VERSIONS_API_ENV = "BASE44_VERSIONS_API";
249909
- function versionsApiEnabled(env = process.env) {
249910
- const value = env[VERSIONS_API_ENV];
249911
- return value === "1" || value === "true";
249912
- }
249913
- // src/cli/commands/project/build.ts
249914
- async function buildAction(ctx) {
249915
- const app = requireApp(ctx);
249916
- const target = await resolvePublishTarget(app.projectRoot);
249917
- await runSiteBuild(ctx, {
249918
- root: target.root,
249919
- buildCommand: target.buildCommand,
249920
- appId: app.id
249921
- });
249922
- return {
249923
- outroMessage: `Site built with app id ${theme.styles.bold(app.id)}`
249682
+ outroMessage: `Site built with app id ${theme.styles.bold(app.id)}`
249924
249683
  };
249925
249684
  }
249926
249685
  function getBuildCommand() {
@@ -249928,11 +249687,11 @@ function getBuildCommand() {
249928
249687
  }
249929
249688
 
249930
249689
  // src/cli/commands/project/create.ts
249931
- import { basename as basename6, resolve as resolve12 } from "node:path";
249690
+ import { basename as basename6, resolve as resolve11 } from "node:path";
249932
249691
  var import_kebabCase = __toESM(require_kebabCase(), 1);
249933
249692
 
249934
249693
  // src/cli/commands/project/scaffold-shared.ts
249935
- import { join as join29 } from "node:path";
249694
+ import { join as join28 } from "node:path";
249936
249695
  var DEFAULT_TEMPLATE_ID = "backend-only";
249937
249696
  async function getTemplateById(templateId) {
249938
249697
  const templates = await listTemplates();
@@ -249995,7 +249754,7 @@ async function completeProjectSetup({
249995
249754
  env: { VITE_BASE44_APP_ID: projectId }
249996
249755
  })`${buildCommand}`;
249997
249756
  updateMessage("Deploying site...");
249998
- return await deploySite(join29(resolvedPath, outputDirectory));
249757
+ return await deploySite(join28(resolvedPath, outputDirectory));
249999
249758
  }, {
250000
249759
  successMessage: theme.colors.base44Orange("Site deployed successfully"),
250001
249760
  errorMessage: "Failed to deploy site"
@@ -250124,7 +249883,7 @@ async function createInteractive(options, ctx) {
250124
249883
  }, ctx);
250125
249884
  }
250126
249885
  async function createNonInteractive(options, ctx) {
250127
- ctx.log.info(`Creating a new project at ${resolve12(options.path)}`);
249886
+ ctx.log.info(`Creating a new project at ${resolve11(options.path)}`);
250128
249887
  const template = await getTemplateById(options.template ?? DEFAULT_TEMPLATE_ID);
250129
249888
  return await executeCreate({
250130
249889
  template,
@@ -250148,7 +249907,7 @@ async function executeCreate({
250148
249907
  }, ctx) {
250149
249908
  const { log, runTask } = ctx;
250150
249909
  const name = rawName.trim();
250151
- const resolvedPath = resolve12(projectPath);
249910
+ const resolvedPath = resolve11(projectPath);
250152
249911
  const organizationId = await resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive);
250153
249912
  const { projectId } = await runTask("Setting up your project...", async () => {
250154
249913
  return await createProjectFiles({
@@ -250789,7 +250548,7 @@ function getLogsCommand() {
250789
250548
  }
250790
250549
 
250791
250550
  // src/cli/commands/project/scaffold.ts
250792
- import { basename as basename7, resolve as resolve13 } from "node:path";
250551
+ import { basename as basename7, resolve as resolve12 } from "node:path";
250793
250552
  function resolveAppId(options) {
250794
250553
  const appId = options.appId;
250795
250554
  if (!appId) {
@@ -250805,7 +250564,7 @@ function resolveAppId(options) {
250805
250564
  async function scaffoldAction(ctx, name, options, command) {
250806
250565
  const { log, runTask } = ctx;
250807
250566
  const appId = resolveAppId(command.optsWithGlobals());
250808
- const resolvedPath = resolve13("./");
250567
+ const resolvedPath = resolve12("./");
250809
250568
  const projectName = (name ?? basename7(resolvedPath)).trim();
250810
250569
  const template = await getTemplateById("backend-only");
250811
250570
  log.info(`Scaffolding project at ${resolvedPath}`);
@@ -250853,6 +250612,258 @@ function getVisibilityCommand() {
250853
250612
  ])).action(setVisibility);
250854
250613
  }
250855
250614
 
250615
+ // src/core/version/schema.ts
250616
+ var DeclareVersionResponseSchema = object({
250617
+ session_id: string2(),
250618
+ uploads: array(object({
250619
+ path: string2(),
250620
+ url: string2(),
250621
+ content_type: string2(),
250622
+ content_length: number2(),
250623
+ checksum_sha256: string2()
250624
+ }))
250625
+ }).transform((data) => ({
250626
+ sessionId: data.session_id,
250627
+ uploads: data.uploads.map((upload) => ({
250628
+ path: upload.path,
250629
+ url: upload.url,
250630
+ contentType: upload.content_type,
250631
+ contentLength: upload.content_length,
250632
+ checksumSha256: upload.checksum_sha256
250633
+ }))
250634
+ }));
250635
+ var CreateVersionResponseSchema = object({
250636
+ version_id: string2(),
250637
+ manifest_hash: string2()
250638
+ }).transform((data) => ({
250639
+ versionId: data.version_id,
250640
+ manifestHash: data.manifest_hash
250641
+ }));
250642
+ var EnvironmentResponseSchema = object({
250643
+ name: string2(),
250644
+ version_id: string2(),
250645
+ manifest_hash: string2(),
250646
+ deployment_id: string2()
250647
+ }).transform((data) => ({
250648
+ name: data.name,
250649
+ versionId: data.version_id,
250650
+ manifestHash: data.manifest_hash,
250651
+ deploymentId: data.deployment_id
250652
+ }));
250653
+
250654
+ // src/core/version/api.ts
250655
+ var DEFAULT_VERSION_UPLOAD_CONCURRENCY = 8;
250656
+ var MAX_VERSION_UPLOAD_CONCURRENCY = 16;
250657
+ function declaredFile({ path, size, digest }) {
250658
+ return { path, size, digest };
250659
+ }
250660
+ function declaredModule(module) {
250661
+ return { ...declaredFile(module), type: module.type };
250662
+ }
250663
+ function declaredAssetsConfig(config) {
250664
+ const stated = {
250665
+ html_handling: config?.htmlHandling ?? null,
250666
+ not_found_handling: config?.notFoundHandling ?? null,
250667
+ run_worker_first: config?.runWorkerFirst ?? null,
250668
+ headers: config?.headers ?? null,
250669
+ redirects: config?.redirects ?? null
250670
+ };
250671
+ return Object.values(stated).every((v) => v === null) ? null : stated;
250672
+ }
250673
+ async function post(path, json, doing) {
250674
+ try {
250675
+ return await getAppClient().post(path, { json, timeout: 180000 });
250676
+ } catch (error) {
250677
+ throw await ApiError.fromHttpError(error, doing);
250678
+ }
250679
+ }
250680
+ var KEYED_RETRY = {
250681
+ limit: 3,
250682
+ methods: ["patch"],
250683
+ statusCodes: [408, 500, 502, 503, 504],
250684
+ retryOnTimeout: true
250685
+ };
250686
+ async function patch(path, json, doing, retry) {
250687
+ try {
250688
+ return await getAppClient().patch(path, {
250689
+ json,
250690
+ timeout: 180000,
250691
+ ...retry ? { retry } : {}
250692
+ });
250693
+ } catch (error) {
250694
+ throw await ApiError.fromHttpError(error, doing);
250695
+ }
250696
+ }
250697
+ function parse10(schema, body, what) {
250698
+ const result = schema.safeParse(body);
250699
+ if (!result.success) {
250700
+ throw new SchemaValidationError(`Invalid ${what} response from server`, result.error);
250701
+ }
250702
+ return result.data;
250703
+ }
250704
+ async function createVersion(artifacts, options = {}) {
250705
+ const declared = parse10(DeclareVersionResponseSchema, await (await post("versions", {
250706
+ static_bundle: artifacts.files.map(declaredFile),
250707
+ ...artifacts.siteWorker ? {
250708
+ site_worker: {
250709
+ main: artifacts.siteWorker.main,
250710
+ modules: artifacts.siteWorker.modules.map(declaredModule),
250711
+ assets: artifacts.siteWorker.assets.map(declaredFile),
250712
+ compatibility_date: artifacts.siteWorker.compatibilityDate,
250713
+ compatibility_flags: artifacts.siteWorker.compatibilityFlags,
250714
+ assets_config: declaredAssetsConfig(artifacts.siteWorker.assetsConfig)
250715
+ }
250716
+ } : {},
250717
+ entities: artifacts.entities,
250718
+ agents: artifacts.agents,
250719
+ source_commit: options.sourceCommit
250720
+ }, "declaring a version")).json(), "declare");
250721
+ const declaredFiles = [
250722
+ ...artifacts.files,
250723
+ ...artifacts.siteWorker?.modules ?? [],
250724
+ ...artifacts.siteWorker?.assets ?? []
250725
+ ];
250726
+ options.progress?.onDeclared?.({ fileCount: declaredFiles.length });
250727
+ if (declared.uploads.length !== declaredFiles.length) {
250728
+ throw new InternalError(`Declared ${declaredFiles.length} files but the server signed ${declared.uploads.length} upload URLs.`);
250729
+ }
250730
+ const drifted = declared.uploads.findIndex((upload, index) => upload.path !== declaredFiles[index].path);
250731
+ if (drifted !== -1) {
250732
+ throw new InternalError(`Upload ${drifted} is signed for ${declared.uploads[drifted].path}, but that slot declared ${declaredFiles[drifted].path}.`);
250733
+ }
250734
+ let uploadedFiles = 0;
250735
+ await pMap(declared.uploads, async (upload, index) => {
250736
+ await putPresigned(upload, declaredFiles[index].absolutePath);
250737
+ uploadedFiles++;
250738
+ options.progress?.onUpload?.({
250739
+ uploadedFiles,
250740
+ totalFiles: declared.uploads.length
250741
+ });
250742
+ }, { concurrency: options.concurrency ?? DEFAULT_VERSION_UPLOAD_CONCURRENCY });
250743
+ return parse10(CreateVersionResponseSchema, await (await post(`versions/${encodeURIComponent(declared.sessionId)}/finalize`, {}, "creating a version")).json(), "create version");
250744
+ }
250745
+ async function setEnvironmentVersion(environment, versionId, options = {}) {
250746
+ return parse10(EnvironmentResponseSchema, await (await patch(`environments/${encodeURIComponent(environment)}`, {
250747
+ version_id: versionId,
250748
+ ...options.idempotencyKey ? { idempotency_key: options.idempotencyKey } : {}
250749
+ }, "setting the environment's version", options.idempotencyKey ? KEYED_RETRY : undefined)).json(), "environment");
250750
+ }
250751
+ // src/core/version/artifacts.ts
250752
+ import { createHash as createHash2 } from "node:crypto";
250753
+ import { join as join29, resolve as resolve13 } from "node:path";
250754
+ var MAX_FILE_COUNT = 50000;
250755
+ var HASH_CONCURRENCY = 32;
250756
+ var ENTRY2 = "index.html";
250757
+ async function digestFile(absolutePath) {
250758
+ const hash = await hashFileInto(createHash2("sha256"), absolutePath);
250759
+ return `sha256:${hash.digest("hex")}`;
250760
+ }
250761
+ async function collectBuildOutput(outputDir, options = {}) {
250762
+ const found = await describeBuildOutput(outputDir);
250763
+ if (found.length > MAX_FILE_COUNT) {
250764
+ throw new InvalidInputError(`Too many files: found ${found.length}, the limit is ${MAX_FILE_COUNT}.`);
250765
+ }
250766
+ if (options.entryFile) {
250767
+ if (found.length === 0) {
250768
+ throw new InvalidInputError(`No files found in ${outputDir}. Build the site before creating a version.`, {
250769
+ hints: [
250770
+ { message: "Run 'base44 build' first", command: "base44 build" }
250771
+ ]
250772
+ });
250773
+ }
250774
+ if (!found.some((f) => f.path === options.entryFile)) {
250775
+ throw new InvalidInputError(`${outputDir} has no ${options.entryFile}, so nothing could enter the site.`);
250776
+ }
250777
+ }
250778
+ return await pMap(found, async (file) => ({ ...file, digest: await digestFile(file.absolutePath) }), { concurrency: HASH_CONCURRENCY });
250779
+ }
250780
+ async function collectSiteWorker(projectRoot) {
250781
+ const built = await resolveFullStackBuild(projectRoot);
250782
+ if (!built) {
250783
+ return null;
250784
+ }
250785
+ const { config, modules, assetsDir } = built;
250786
+ const entry = resolve13(config.configDir, config.main);
250787
+ const main = modules.find((m) => m.absolutePath === entry)?.name;
250788
+ if (!main) {
250789
+ throw new InvalidInputError(`The Worker's entry module ${config.main} is not among the ${modules.length} modules collected from ${config.configDir}.`);
250790
+ }
250791
+ return {
250792
+ main,
250793
+ modules: await pMap(modules, async ({ name, absolutePath, size, type }) => ({
250794
+ path: name,
250795
+ absolutePath,
250796
+ size,
250797
+ digest: await digestFile(absolutePath),
250798
+ type
250799
+ }), { concurrency: HASH_CONCURRENCY }),
250800
+ assets: assetsDir ? await collectBuildOutput(assetsDir) : [],
250801
+ compatibilityDate: config.compatibilityDate,
250802
+ compatibilityFlags: config.compatibilityFlags,
250803
+ assetsConfig: config.assetsConfig
250804
+ };
250805
+ }
250806
+ async function readRawResources(dir) {
250807
+ if (!await pathExists(dir)) {
250808
+ return {};
250809
+ }
250810
+ const files = await globby(`**/*.${CONFIG_FILE_EXTENSION_GLOB}`, {
250811
+ cwd: dir,
250812
+ onlyFiles: true,
250813
+ followSymbolicLinks: false
250814
+ });
250815
+ const payloads = {};
250816
+ for (const relativePath of files.sort()) {
250817
+ const name = relativePath.replace(/\.jsonc?$/, "");
250818
+ payloads[name] = await readJsonFile(join29(dir, ...relativePath.split("/")));
250819
+ }
250820
+ return payloads;
250821
+ }
250822
+ async function collectResources(configDir, dirs) {
250823
+ const [entities, agents] = await Promise.all([
250824
+ readRawResources(join29(configDir, dirs.entitiesDir)),
250825
+ readRawResources(join29(configDir, dirs.agentsDir))
250826
+ ]);
250827
+ return { entities, agents };
250828
+ }
250829
+ async function collectArtifacts(target) {
250830
+ const siteWorker = await collectSiteWorker(target.root);
250831
+ return {
250832
+ files: siteWorker ? [] : await collectBuildOutput(requireOutputDir(target), {
250833
+ entryFile: ENTRY2
250834
+ }),
250835
+ ...siteWorker ? { siteWorker } : {},
250836
+ ...await collectResources(target.configDir, target)
250837
+ };
250838
+ }
250839
+ // src/core/version/gate.ts
250840
+ var VERSIONS_API_ENV = "BASE44_VERSIONS_API";
250841
+ function versionsApiEnabled(env = process.env) {
250842
+ const value = env[VERSIONS_API_ENV];
250843
+ return value === "1" || value === "true";
250844
+ }
250845
+ // src/core/version/publish.ts
250846
+ import { randomUUID as randomUUID4 } from "node:crypto";
250847
+ var DEFAULT_ENVIRONMENT = "production";
250848
+ async function tagStep2(step, run) {
250849
+ return await tagStep(step, run);
250850
+ }
250851
+ async function publishVersion(artifacts, options = {}) {
250852
+ const version = await tagStep2("create_version", () => createVersion(artifacts, {
250853
+ sourceCommit: options.sourceCommit,
250854
+ concurrency: options.concurrency,
250855
+ progress: options.progress
250856
+ }));
250857
+ const environment = await tagStep2("deploy", () => setEnvironmentVersion(options.target ?? DEFAULT_ENVIRONMENT, version.versionId, {
250858
+ idempotencyKey: randomUUID4()
250859
+ }));
250860
+ return {
250861
+ environment: environment.name,
250862
+ versionId: environment.versionId,
250863
+ manifestHash: environment.manifestHash,
250864
+ deploymentId: environment.deploymentId
250865
+ };
250866
+ }
250856
250867
  // src/cli/commands/versions/options.ts
250857
250868
  function outputDirOption() {
250858
250869
  return new Option2("--output-dir <dir>", "Build output directory (defaults to the project's, else dist)");
@@ -250882,9 +250893,9 @@ function concurrencyOption() {
250882
250893
  async function publishAction(ctx, options) {
250883
250894
  const { runTask, log, jsonMode } = ctx;
250884
250895
  const app = requireApp(ctx);
250885
- const target = await tagStep("create_version", () => resolvePublishTarget(app.projectRoot, { outputDir: options.outputDir }));
250896
+ const target = await tagStep2("create_version", () => resolveBuildTarget(app.projectRoot, { outputDir: options.outputDir }));
250886
250897
  if (options.build !== false) {
250887
- await tagStep("build", () => runSiteBuild(ctx, {
250898
+ await tagStep2("build", () => runSiteBuild(ctx, {
250888
250899
  root: target.root,
250889
250900
  buildCommand: target.buildCommand,
250890
250901
  appId: app.id
@@ -250892,7 +250903,7 @@ async function publishAction(ctx, options) {
250892
250903
  }
250893
250904
  const gitHash = await resolveProvenanceCommit(target.root, options.gitHash);
250894
250905
  const result = await runTask("Publishing...", async (updateMessage) => {
250895
- const artifacts = await tagStep("create_version", () => collectArtifacts(target));
250906
+ const artifacts = await tagStep2("create_version", () => collectArtifacts(target));
250896
250907
  return await publishVersion(artifacts, {
250897
250908
  sourceCommit: gitHash,
250898
250909
  target: options.target,
@@ -251626,7 +251637,7 @@ function getTypesCommand() {
251626
251637
  // src/cli/commands/versions/create.ts
251627
251638
  async function createAction2(ctx, options) {
251628
251639
  const { runTask, jsonMode } = ctx;
251629
- const target = await resolvePublishTarget(requireApp(ctx).projectRoot, {
251640
+ const target = await resolveBuildTarget(requireApp(ctx).projectRoot, {
251630
251641
  outputDir: options.outputDir
251631
251642
  });
251632
251643
  const gitHash = await resolveProvenanceCommit(target.root, options.gitHash);
@@ -260392,4 +260403,4 @@ export {
260392
260403
  runCLI
260393
260404
  };
260394
260405
 
260395
- //# debugId=45EEED102FF0084464756E2164756E21
260406
+ //# debugId=4A0444E0B8A1C5CD64756E2164756E21