@base44-preview/cli 0.1.15-pr.626.6cd5550 → 0.1.15-pr.626.6dabe64

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
@@ -239590,94 +239590,8 @@ async function createArchive(pathToArchive, targetArchivePath) {
239590
239590
  import { readFile as readFile3 } from "node:fs/promises";
239591
239591
  import { join as join18 } from "node:path";
239592
239592
 
239593
- // src/core/site/manifest.ts
239594
- import { createHash } from "node:crypto";
239595
- import { createReadStream } from "node:fs";
239596
- import { stat } from "node:fs/promises";
239597
- import { basename as basename5, extname, join as join16 } from "node:path";
239598
- var MAX_ASSET_COUNT = 1e5;
239599
- var ASSETS_IGNORE_FILE = ".assetsignore";
239600
- var ALWAYS_IGNORED = new Set([
239601
- ASSETS_IGNORE_FILE,
239602
- "wrangler.json",
239603
- ".dev.vars"
239604
- ]);
239605
- var MIME_TYPES = {
239606
- ".html": "text/html",
239607
- ".htm": "text/html",
239608
- ".css": "text/css",
239609
- ".js": "text/javascript",
239610
- ".mjs": "text/javascript",
239611
- ".json": "application/json",
239612
- ".map": "application/json",
239613
- ".txt": "text/plain",
239614
- ".xml": "application/xml",
239615
- ".svg": "image/svg+xml",
239616
- ".png": "image/png",
239617
- ".jpg": "image/jpeg",
239618
- ".jpeg": "image/jpeg",
239619
- ".gif": "image/gif",
239620
- ".webp": "image/webp",
239621
- ".avif": "image/avif",
239622
- ".ico": "image/x-icon",
239623
- ".woff": "font/woff",
239624
- ".woff2": "font/woff2",
239625
- ".ttf": "font/ttf",
239626
- ".otf": "font/otf",
239627
- ".eot": "application/vnd.ms-fontobject",
239628
- ".mp3": "audio/mpeg",
239629
- ".mp4": "video/mp4",
239630
- ".webm": "video/webm",
239631
- ".pdf": "application/pdf",
239632
- ".wasm": "application/wasm",
239633
- ".webmanifest": "application/manifest+json"
239634
- };
239635
- function getAssetContentType(filePath) {
239636
- return MIME_TYPES[extname(filePath).toLowerCase()] ?? "application/octet-stream";
239637
- }
239638
- async function walkBuildOutput(outputDir) {
239639
- const found = await globby("**/*", {
239640
- cwd: outputDir,
239641
- dot: true,
239642
- onlyFiles: true,
239643
- followSymbolicLinks: false,
239644
- ignoreFiles: [ASSETS_IGNORE_FILE]
239645
- });
239646
- return found.filter((path) => !ALWAYS_IGNORED.has(basename5(path))).sort();
239647
- }
239648
- async function hashAssetFile(appId, absolutePath) {
239649
- const hash = createHash("sha256").update(Buffer.from(appId, "utf8"));
239650
- for await (const chunk of createReadStream(absolutePath)) {
239651
- hash.update(chunk);
239652
- }
239653
- return hash.digest("hex").slice(0, 32);
239654
- }
239655
- async function buildAssetManifest(assetsDir, appId) {
239656
- const manifest = {};
239657
- const filesByHash = new Map;
239658
- const relativeFilePaths = await walkBuildOutput(assetsDir);
239659
- if (relativeFilePaths.length > MAX_ASSET_COUNT) {
239660
- throw new InvalidInputError(`Too many static assets: found ${relativeFilePaths.length}, the limit is ${MAX_ASSET_COUNT} files.`);
239661
- }
239662
- for (const relativePath of relativeFilePaths) {
239663
- const absolutePath = join16(assetsDir, ...relativePath.split("/"));
239664
- const { size } = await stat(absolutePath);
239665
- const hash = await hashAssetFile(appId, absolutePath);
239666
- manifest[`/${relativePath}`] = { hash, size };
239667
- if (!filesByHash.has(hash)) {
239668
- filesByHash.set(hash, {
239669
- absolutePath,
239670
- hash,
239671
- size,
239672
- contentType: getAssetContentType(absolutePath)
239673
- });
239674
- }
239675
- }
239676
- return { manifest, filesByHash };
239677
- }
239678
-
239679
239593
  // src/core/site/modules.ts
239680
- import { stat as stat2 } from "node:fs/promises";
239594
+ import { stat } from "node:fs/promises";
239681
239595
  import { relative as relative5, resolve as resolve3, sep } from "node:path";
239682
239596
  var MAX_TOTAL_MODULE_BYTES = 40 * 1024 * 1024;
239683
239597
  var MODULE_IGNORE = ["wrangler.json", ".dev.vars"];
@@ -239752,7 +239666,7 @@ async function collectModules(config) {
239752
239666
  const modules = [...modulesByName.values()];
239753
239667
  let totalBytes = 0;
239754
239668
  for (const module of modules) {
239755
- module.size = (await stat2(module.absolutePath)).size;
239669
+ module.size = (await stat(module.absolutePath)).size;
239756
239670
  totalBytes += module.size;
239757
239671
  }
239758
239672
  if (totalBytes > MAX_TOTAL_MODULE_BYTES) {
@@ -239771,8 +239685,104 @@ function addSourcemap(modulesByName, configDir, name) {
239771
239685
  });
239772
239686
  }
239773
239687
 
239774
- // src/core/site/upload.ts
239775
- import { readFile as readFile2 } from "node:fs/promises";
239688
+ // src/core/site/wrangler-config.ts
239689
+ import { dirname as dirname12, join as join16, resolve as resolve4 } from "node:path";
239690
+ var WRANGLER_REDIRECT_PATH = join16(".wrangler", "deploy", "config.json");
239691
+ var RedirectConfigSchema = looseObject({
239692
+ configPath: string2().min(1)
239693
+ });
239694
+ var WranglerConfigSchema = looseObject({
239695
+ main: string2().min(1, "wrangler config is missing a 'main' entry module"),
239696
+ no_bundle: boolean2().optional(),
239697
+ rules: array(looseObject({ type: string2(), globs: array(string2()) })).optional(),
239698
+ assets: looseObject({
239699
+ directory: string2().optional(),
239700
+ html_handling: string2().optional(),
239701
+ not_found_handling: string2().optional(),
239702
+ run_worker_first: union([boolean2(), array(string2())]).optional(),
239703
+ headers: string2().optional(),
239704
+ redirects: string2().optional()
239705
+ }).optional(),
239706
+ compatibility_date: string2().optional(),
239707
+ compatibility_flags: array(string2()).optional(),
239708
+ vars: record(string2(), unknown()).optional(),
239709
+ upload_source_maps: boolean2().optional()
239710
+ });
239711
+ async function detectFullStackArtifact(projectRoot) {
239712
+ const redirectPath = join16(projectRoot, WRANGLER_REDIRECT_PATH);
239713
+ return await pathExists(redirectPath) ? redirectPath : null;
239714
+ }
239715
+ async function resolveWranglerConfig(redirectPath) {
239716
+ const configPath = await resolveRedirectedConfigPath(redirectPath);
239717
+ const parsed = await readJsonFile(configPath);
239718
+ const result = WranglerConfigSchema.safeParse(parsed);
239719
+ if (!result.success) {
239720
+ throw new ConfigInvalidError(`Invalid wrangler config: ${prettifyError(result.error)}`, configPath);
239721
+ }
239722
+ const config = result.data;
239723
+ if (config.no_bundle !== true) {
239724
+ throw new InvalidInputError("This framework's output requires bundling; not yet supported. Base44 only deploys pre-bundled Workers output (no_bundle: true).");
239725
+ }
239726
+ const configDir = dirname12(configPath);
239727
+ const assetsDirectory = config.assets?.directory ? resolve4(configDir, config.assets.directory) : null;
239728
+ return {
239729
+ configPath,
239730
+ configDir,
239731
+ main: config.main,
239732
+ assetsDirectory,
239733
+ assetsConfig: config.assets ? toResolvedAssetsConfig(config.assets) : null,
239734
+ compatibilityDate: config.compatibility_date ?? null,
239735
+ compatibilityFlags: config.compatibility_flags ?? [],
239736
+ rules: (config.rules ?? []).map((rule) => ({
239737
+ type: rule.type,
239738
+ globs: rule.globs
239739
+ })),
239740
+ uploadSourceMaps: config.upload_source_maps ?? false
239741
+ };
239742
+ }
239743
+ async function resolveRedirectedConfigPath(redirectPath) {
239744
+ const parsed = await readJsonFile(redirectPath);
239745
+ const result = RedirectConfigSchema.safeParse(parsed);
239746
+ if (!result.success) {
239747
+ throw new ConfigInvalidError(`Invalid deploy redirect file: ${prettifyError(result.error)}`, redirectPath);
239748
+ }
239749
+ const configPath = resolve4(dirname12(redirectPath), result.data.configPath);
239750
+ if (!await pathExists(configPath)) {
239751
+ throw new ConfigInvalidError(`Wrangler config referenced by ${redirectPath} does not exist: ${configPath}`, redirectPath, {
239752
+ hints: [{ message: "Rebuild the project to regenerate the artifact" }]
239753
+ });
239754
+ }
239755
+ return configPath;
239756
+ }
239757
+ function toResolvedAssetsConfig(assets) {
239758
+ return {
239759
+ htmlHandling: assets.html_handling,
239760
+ notFoundHandling: assets.not_found_handling,
239761
+ runWorkerFirst: assets.run_worker_first,
239762
+ headers: assets.headers,
239763
+ redirects: assets.redirects
239764
+ };
239765
+ }
239766
+
239767
+ // src/core/site/full-stack.ts
239768
+ async function resolveFullStackBuild(projectRoot) {
239769
+ const redirectPath = await detectFullStackArtifact(projectRoot);
239770
+ if (!redirectPath) {
239771
+ return null;
239772
+ }
239773
+ const config = await resolveWranglerConfig(redirectPath);
239774
+ return {
239775
+ config,
239776
+ modules: await collectModules(config),
239777
+ assetsDir: config.assetsDirectory && await pathExists(config.assetsDirectory) ? config.assetsDirectory : null
239778
+ };
239779
+ }
239780
+
239781
+ // src/core/site/manifest.ts
239782
+ import { createHash } from "node:crypto";
239783
+ import { createReadStream } from "node:fs";
239784
+ import { stat as stat2 } from "node:fs/promises";
239785
+ import { basename as basename5, extname, join as join17 } from "node:path";
239776
239786
 
239777
239787
  // ../../node_modules/p-map/index.js
239778
239788
  async function pMap(iterable, mapper, {
@@ -239898,7 +239908,99 @@ async function pMap(iterable, mapper, {
239898
239908
  }
239899
239909
  var pMapSkip = Symbol("skip");
239900
239910
 
239911
+ // src/core/site/manifest.ts
239912
+ var MAX_ASSET_COUNT = 1e5;
239913
+ var ASSETS_IGNORE_FILE = ".assetsignore";
239914
+ var ALWAYS_IGNORED = new Set([
239915
+ ASSETS_IGNORE_FILE,
239916
+ "wrangler.json",
239917
+ ".dev.vars"
239918
+ ]);
239919
+ var MIME_TYPES = {
239920
+ ".html": "text/html",
239921
+ ".htm": "text/html",
239922
+ ".css": "text/css",
239923
+ ".js": "text/javascript",
239924
+ ".mjs": "text/javascript",
239925
+ ".json": "application/json",
239926
+ ".map": "application/json",
239927
+ ".txt": "text/plain",
239928
+ ".xml": "application/xml",
239929
+ ".svg": "image/svg+xml",
239930
+ ".png": "image/png",
239931
+ ".jpg": "image/jpeg",
239932
+ ".jpeg": "image/jpeg",
239933
+ ".gif": "image/gif",
239934
+ ".webp": "image/webp",
239935
+ ".avif": "image/avif",
239936
+ ".ico": "image/x-icon",
239937
+ ".woff": "font/woff",
239938
+ ".woff2": "font/woff2",
239939
+ ".ttf": "font/ttf",
239940
+ ".otf": "font/otf",
239941
+ ".eot": "application/vnd.ms-fontobject",
239942
+ ".mp3": "audio/mpeg",
239943
+ ".mp4": "video/mp4",
239944
+ ".webm": "video/webm",
239945
+ ".pdf": "application/pdf",
239946
+ ".wasm": "application/wasm",
239947
+ ".webmanifest": "application/manifest+json"
239948
+ };
239949
+ function getAssetContentType(filePath) {
239950
+ return MIME_TYPES[extname(filePath).toLowerCase()] ?? "application/octet-stream";
239951
+ }
239952
+ async function walkBuildOutput(outputDir) {
239953
+ const found = await globby("**/*", {
239954
+ cwd: outputDir,
239955
+ dot: true,
239956
+ onlyFiles: true,
239957
+ followSymbolicLinks: false,
239958
+ ignoreFiles: [ASSETS_IGNORE_FILE]
239959
+ });
239960
+ return found.filter((path) => !ALWAYS_IGNORED.has(basename5(path))).sort();
239961
+ }
239962
+ var STAT_CONCURRENCY = 32;
239963
+ async function describeBuildOutput(outputDir) {
239964
+ const relativePaths = await walkBuildOutput(outputDir);
239965
+ return await pMap(relativePaths, async (path) => {
239966
+ const absolutePath = join17(outputDir, ...path.split("/"));
239967
+ return { path, absolutePath, size: (await stat2(absolutePath)).size };
239968
+ }, { concurrency: STAT_CONCURRENCY });
239969
+ }
239970
+ async function hashFileInto(hash, absolutePath) {
239971
+ for await (const chunk of createReadStream(absolutePath)) {
239972
+ hash.update(chunk);
239973
+ }
239974
+ return hash;
239975
+ }
239976
+ async function hashAssetFile(appId, absolutePath) {
239977
+ const hash = await hashFileInto(createHash("sha256").update(Buffer.from(appId, "utf8")), absolutePath);
239978
+ return hash.digest("hex").slice(0, 32);
239979
+ }
239980
+ async function buildAssetManifest(assetsDir, appId) {
239981
+ const manifest = {};
239982
+ const filesByHash = new Map;
239983
+ const files = await describeBuildOutput(assetsDir);
239984
+ if (files.length > MAX_ASSET_COUNT) {
239985
+ throw new InvalidInputError(`Too many static assets: found ${files.length}, the limit is ${MAX_ASSET_COUNT} files.`);
239986
+ }
239987
+ for (const { path: relativePath, absolutePath, size } of files) {
239988
+ const hash = await hashAssetFile(appId, absolutePath);
239989
+ manifest[`/${relativePath}`] = { hash, size };
239990
+ if (!filesByHash.has(hash)) {
239991
+ filesByHash.set(hash, {
239992
+ absolutePath,
239993
+ hash,
239994
+ size,
239995
+ contentType: getAssetContentType(absolutePath)
239996
+ });
239997
+ }
239998
+ }
239999
+ return { manifest, filesByHash };
240000
+ }
240001
+
239901
240002
  // src/core/site/upload.ts
240003
+ import { readFile as readFile2 } from "node:fs/promises";
239902
240004
  var DEFAULT_UPLOAD_CONCURRENCY = 3;
239903
240005
  var MAX_UPLOAD_CONCURRENCY = 50;
239904
240006
  var MAX_UPLOAD_ATTEMPTS = 3;
@@ -240016,85 +240118,6 @@ async function putPresigned(upload, absolutePath) {
240016
240118
  }
240017
240119
  }
240018
240120
 
240019
- // src/core/site/wrangler-config.ts
240020
- import { dirname as dirname12, join as join17, resolve as resolve4 } from "node:path";
240021
- var WRANGLER_REDIRECT_PATH = join17(".wrangler", "deploy", "config.json");
240022
- var RedirectConfigSchema = looseObject({
240023
- configPath: string2().min(1)
240024
- });
240025
- var WranglerConfigSchema = looseObject({
240026
- main: string2().min(1, "wrangler config is missing a 'main' entry module"),
240027
- no_bundle: boolean2().optional(),
240028
- rules: array(looseObject({ type: string2(), globs: array(string2()) })).optional(),
240029
- assets: looseObject({
240030
- directory: string2().optional(),
240031
- html_handling: string2().optional(),
240032
- not_found_handling: string2().optional(),
240033
- run_worker_first: union([boolean2(), array(string2())]).optional(),
240034
- headers: string2().optional(),
240035
- redirects: string2().optional()
240036
- }).optional(),
240037
- compatibility_date: string2().optional(),
240038
- compatibility_flags: array(string2()).optional(),
240039
- vars: record(string2(), unknown()).optional(),
240040
- upload_source_maps: boolean2().optional()
240041
- });
240042
- async function detectFullStackArtifact(projectRoot) {
240043
- const redirectPath = join17(projectRoot, WRANGLER_REDIRECT_PATH);
240044
- return await pathExists(redirectPath) ? redirectPath : null;
240045
- }
240046
- async function resolveWranglerConfig(redirectPath) {
240047
- const configPath = await resolveRedirectedConfigPath(redirectPath);
240048
- const parsed = await readJsonFile(configPath);
240049
- const result = WranglerConfigSchema.safeParse(parsed);
240050
- if (!result.success) {
240051
- throw new ConfigInvalidError(`Invalid wrangler config: ${prettifyError(result.error)}`, configPath);
240052
- }
240053
- const config = result.data;
240054
- if (config.no_bundle !== true) {
240055
- throw new InvalidInputError("This framework's output requires bundling; not yet supported. Base44 only deploys pre-bundled Workers output (no_bundle: true).");
240056
- }
240057
- const configDir = dirname12(configPath);
240058
- const assetsDirectory = config.assets?.directory ? resolve4(configDir, config.assets.directory) : null;
240059
- return {
240060
- configPath,
240061
- configDir,
240062
- main: config.main,
240063
- assetsDirectory,
240064
- assetsConfig: config.assets ? toResolvedAssetsConfig(config.assets) : null,
240065
- compatibilityDate: config.compatibility_date ?? null,
240066
- compatibilityFlags: config.compatibility_flags ?? [],
240067
- rules: (config.rules ?? []).map((rule) => ({
240068
- type: rule.type,
240069
- globs: rule.globs
240070
- })),
240071
- uploadSourceMaps: config.upload_source_maps ?? false
240072
- };
240073
- }
240074
- async function resolveRedirectedConfigPath(redirectPath) {
240075
- const parsed = await readJsonFile(redirectPath);
240076
- const result = RedirectConfigSchema.safeParse(parsed);
240077
- if (!result.success) {
240078
- throw new ConfigInvalidError(`Invalid deploy redirect file: ${prettifyError(result.error)}`, redirectPath);
240079
- }
240080
- const configPath = resolve4(dirname12(redirectPath), result.data.configPath);
240081
- if (!await pathExists(configPath)) {
240082
- throw new ConfigInvalidError(`Wrangler config referenced by ${redirectPath} does not exist: ${configPath}`, redirectPath, {
240083
- hints: [{ message: "Rebuild the project to regenerate the artifact" }]
240084
- });
240085
- }
240086
- return configPath;
240087
- }
240088
- function toResolvedAssetsConfig(assets) {
240089
- return {
240090
- htmlHandling: assets.html_handling,
240091
- notFoundHandling: assets.not_found_handling,
240092
- runWorkerFirst: assets.run_worker_first,
240093
- headers: assets.headers,
240094
- redirects: assets.redirects
240095
- };
240096
- }
240097
-
240098
240121
  // src/core/site/deployment.ts
240099
240122
  var NO_ASSETS = { manifest: {}, filesByHash: new Map };
240100
240123
  var DEPLOYMENTS_API_ENV = "BASE44_DEPLOYMENTS_API";
@@ -240121,12 +240144,11 @@ async function deployToDeployments(options) {
240121
240144
  return { deploymentId: finalized.deploymentId, gitHash };
240122
240145
  }
240123
240146
  async function resolveWorkerBuild(projectRoot, progress) {
240124
- const redirectPath = await detectFullStackArtifact(projectRoot);
240125
- if (!redirectPath) {
240147
+ const built = await resolveFullStackBuild(projectRoot);
240148
+ if (!built) {
240126
240149
  return null;
240127
240150
  }
240128
- const config = await resolveWranglerConfig(redirectPath);
240129
- const assetsDir = config.assetsDirectory && await pathExists(config.assetsDirectory) ? config.assetsDirectory : null;
240151
+ const { config, modules, assetsDir } = built;
240130
240152
  return {
240131
240153
  config: {
240132
240154
  main: config.main,
@@ -240134,7 +240156,7 @@ async function resolveWorkerBuild(projectRoot, progress) {
240134
240156
  compatibility_flags: config.compatibilityFlags,
240135
240157
  assets: buildAssetsConfig(config.assetsConfig, progress)
240136
240158
  },
240137
- modules: await collectModules(config),
240159
+ modules,
240138
240160
  assetsDir
240139
240161
  };
240140
240162
  }
@@ -247054,6 +247076,12 @@ async function ensureAppContext(ctx, options = {}) {
247054
247076
  ctx.app = appContext;
247055
247077
  ctx.errorReporter.setContext({ appId: appContext.id });
247056
247078
  }
247079
+ function requireApp(ctx) {
247080
+ if (!ctx.app) {
247081
+ throw new InternalError("This command read an app context it never resolved — it is declared with requireAppContext: false.");
247082
+ }
247083
+ return ctx.app;
247084
+ }
247057
247085
 
247058
247086
  // src/cli/utils/version-check.ts
247059
247087
  async function checkForUpgrade() {
@@ -247296,6 +247324,7 @@ async function createVersion(artifacts, options = {}) {
247296
247324
  site_worker: {
247297
247325
  main: artifacts.siteWorker.main,
247298
247326
  modules: artifacts.siteWorker.modules.map(declaredFile),
247327
+ assets: artifacts.siteWorker.assets.map(declaredFile),
247299
247328
  compatibility_date: artifacts.siteWorker.compatibilityDate,
247300
247329
  compatibility_flags: artifacts.siteWorker.compatibilityFlags
247301
247330
  }
@@ -247306,15 +247335,17 @@ async function createVersion(artifacts, options = {}) {
247306
247335
  }, "declaring a version")).json(), "declare");
247307
247336
  const declaredFiles = [
247308
247337
  ...artifacts.files,
247309
- ...artifacts.siteWorker?.modules ?? []
247338
+ ...artifacts.siteWorker?.modules ?? [],
247339
+ ...artifacts.siteWorker?.assets ?? []
247310
247340
  ];
247311
- options.progress?.onDeclared?.({
247312
- fileCount: declaredFiles.length,
247313
- owedFiles: declared.uploads.length
247314
- });
247341
+ options.progress?.onDeclared?.({ fileCount: declaredFiles.length });
247315
247342
  if (declared.uploads.length !== declaredFiles.length) {
247316
247343
  throw new InternalError(`Declared ${declaredFiles.length} files but the server signed ${declared.uploads.length} upload URLs.`);
247317
247344
  }
247345
+ const drifted = declared.uploads.findIndex((upload, index) => upload.path !== declaredFiles[index].path);
247346
+ if (drifted !== -1) {
247347
+ throw new InternalError(`Upload ${drifted} is signed for ${declared.uploads[drifted].path}, but that slot declared ${declaredFiles[drifted].path}.`);
247348
+ }
247318
247349
  let uploadedFiles = 0;
247319
247350
  await pMap(declared.uploads, async (upload, index) => {
247320
247351
  await putPresigned(upload, declaredFiles[index].absolutePath);
@@ -247340,7 +247371,7 @@ async function tagStep(step, run) {
247340
247371
  try {
247341
247372
  return await run();
247342
247373
  } catch (error) {
247343
- if (error !== null && typeof error === "object" && !(STEP in error)) {
247374
+ if (error !== null && typeof error === "object" && !(STEP in error) && Object.isExtensible(error)) {
247344
247375
  Object.defineProperty(error, STEP, { value: step, enumerable: false });
247345
247376
  }
247346
247377
  throw error;
@@ -249731,53 +249762,84 @@ async function maybeAskToBuild(isNonInteractive, buildCommand) {
249731
249762
  }
249732
249763
  // src/core/version/artifacts.ts
249733
249764
  import { createHash as createHash2 } from "node:crypto";
249734
- import { createReadStream as createReadStream3 } from "node:fs";
249735
- import { stat as stat3 } from "node:fs/promises";
249736
- import { join as join27, resolve as resolve10 } from "node:path";
249765
+ import { join as join28, resolve as resolve11 } from "node:path";
249766
+
249767
+ // src/core/version/project.ts
249768
+ import { dirname as dirname21, join as join27, resolve as resolve10 } from "node:path";
249769
+ var DEFAULT_BUILD_COMMAND = "npm run build";
249770
+ var DEFAULT_OUTPUT_DIRECTORY = "dist";
249771
+ async function resolvePublishTarget(projectRoot, overrides = {}) {
249772
+ const project = await readSettingsIfPresent(projectRoot);
249773
+ const root = project?.root ?? projectRoot ?? process.cwd();
249774
+ return {
249775
+ root,
249776
+ configDir: project ? dirname21(project.configPath) : join27(root, PROJECT_SUBDIR),
249777
+ buildCommand: project ? project.site?.buildCommand : DEFAULT_BUILD_COMMAND,
249778
+ outputDir: outputDirectory(project, root, overrides.outputDir),
249779
+ entitiesDir: project?.entitiesDir ?? "entities",
249780
+ agentsDir: project?.agentsDir ?? "agents"
249781
+ };
249782
+ }
249783
+ function outputDirectory(project, root, override) {
249784
+ const configured = override ?? (project ? project.site?.outputDirectory : DEFAULT_OUTPUT_DIRECTORY);
249785
+ return configured ? resolve10(root, configured) : null;
249786
+ }
249787
+ function requireOutputDir(target) {
249788
+ if (target.outputDir === null) {
249789
+ throw new ConfigNotFoundError("No site configuration found.", {
249790
+ hints: [
249791
+ {
249792
+ message: `Add 'site.outputDirectory' to your config.jsonc (e.g., "site": { "outputDirectory": "dist" })`
249793
+ },
249794
+ { message: `Or pass --output-dir <dir>, relative to ${target.root}` }
249795
+ ]
249796
+ });
249797
+ }
249798
+ return target.outputDir;
249799
+ }
249800
+ async function readSettingsIfPresent(projectRoot) {
249801
+ try {
249802
+ return await readProjectSettings(projectRoot);
249803
+ } catch (error) {
249804
+ if (error instanceof ConfigNotFoundError) {
249805
+ return null;
249806
+ }
249807
+ throw error;
249808
+ }
249809
+ }
249810
+
249811
+ // src/core/version/artifacts.ts
249737
249812
  var MAX_FILE_COUNT = 50000;
249738
249813
  var HASH_CONCURRENCY = 32;
249739
249814
  var ENTRY2 = "index.html";
249740
249815
  async function digestFile(absolutePath) {
249741
- const hash = createHash2("sha256");
249742
- for await (const chunk of createReadStream3(absolutePath)) {
249743
- hash.update(chunk);
249744
- }
249816
+ const hash = await hashFileInto(createHash2("sha256"), absolutePath);
249745
249817
  return `sha256:${hash.digest("hex")}`;
249746
249818
  }
249747
249819
  async function collectBuildOutput(outputDir, options = {}) {
249748
- const relativePaths = await walkBuildOutput(outputDir);
249749
- if (relativePaths.length === 0) {
249820
+ const found = await describeBuildOutput(outputDir);
249821
+ if (found.length === 0) {
249750
249822
  throw new InvalidInputError(`No files found in ${outputDir}. Build the site before creating a version.`, {
249751
249823
  hints: [
249752
249824
  { message: "Run 'base44 build' first", command: "base44 build" }
249753
249825
  ]
249754
249826
  });
249755
249827
  }
249756
- if (relativePaths.length > MAX_FILE_COUNT) {
249757
- throw new InvalidInputError(`Too many files: found ${relativePaths.length}, the limit is ${MAX_FILE_COUNT}.`);
249828
+ if (found.length > MAX_FILE_COUNT) {
249829
+ throw new InvalidInputError(`Too many files: found ${found.length}, the limit is ${MAX_FILE_COUNT}.`);
249758
249830
  }
249759
- if (options.requireEntry !== false && !relativePaths.includes(ENTRY2)) {
249831
+ if (options.requireEntry !== false && !found.some((f) => f.path === ENTRY2)) {
249760
249832
  throw new InvalidInputError(`${outputDir} has no ${ENTRY2}, so nothing could enter the site.`);
249761
249833
  }
249762
- return await pMap(relativePaths, async (path) => {
249763
- const absolutePath = join27(outputDir, ...path.split("/"));
249764
- const { size } = await stat3(absolutePath);
249765
- return {
249766
- path,
249767
- absolutePath,
249768
- size,
249769
- digest: await digestFile(absolutePath)
249770
- };
249771
- }, { concurrency: HASH_CONCURRENCY });
249834
+ return await pMap(found, async (file) => ({ ...file, digest: await digestFile(file.absolutePath) }), { concurrency: HASH_CONCURRENCY });
249772
249835
  }
249773
249836
  async function collectSiteWorker(projectRoot) {
249774
- const redirectPath = await detectFullStackArtifact(projectRoot);
249775
- if (!redirectPath) {
249837
+ const built = await resolveFullStackBuild(projectRoot);
249838
+ if (!built) {
249776
249839
  return null;
249777
249840
  }
249778
- const config = await resolveWranglerConfig(redirectPath);
249779
- const modules = await collectModules(config);
249780
- const entry = resolve10(config.configDir, config.main);
249841
+ const { config, modules, assetsDir } = built;
249842
+ const entry = resolve11(config.configDir, config.main);
249781
249843
  const main = modules.find((m) => m.absolutePath === entry)?.name;
249782
249844
  if (!main) {
249783
249845
  throw new InvalidInputError(`The Worker's entry module ${config.main} is not among the ${modules.length} modules collected from ${config.configDir}.`);
@@ -249790,9 +249852,9 @@ async function collectSiteWorker(projectRoot) {
249790
249852
  size,
249791
249853
  digest: await digestFile(absolutePath)
249792
249854
  }), { concurrency: HASH_CONCURRENCY }),
249855
+ assets: assetsDir ? await collectBuildOutput(assetsDir, { requireEntry: false }) : [],
249793
249856
  compatibilityDate: config.compatibilityDate,
249794
- compatibilityFlags: config.compatibilityFlags,
249795
- assetsDir: config.assetsDirectory && await pathExists(config.assetsDirectory) ? config.assetsDirectory : null
249857
+ compatibilityFlags: config.compatibilityFlags
249796
249858
  };
249797
249859
  }
249798
249860
  async function readRawResources(dir) {
@@ -249807,77 +249869,42 @@ async function readRawResources(dir) {
249807
249869
  const payloads = {};
249808
249870
  for (const relativePath of files.sort()) {
249809
249871
  const name = relativePath.replace(/\.jsonc?$/, "");
249810
- payloads[name] = await readJsonFile(join27(dir, ...relativePath.split("/")));
249872
+ payloads[name] = await readJsonFile(join28(dir, ...relativePath.split("/")));
249811
249873
  }
249812
249874
  return payloads;
249813
249875
  }
249814
249876
  async function collectResources(configDir, dirs) {
249815
249877
  const [entities, agents] = await Promise.all([
249816
- readRawResources(join27(configDir, dirs.entitiesDir)),
249817
- readRawResources(join27(configDir, dirs.agentsDir))
249878
+ readRawResources(join28(configDir, dirs.entitiesDir)),
249879
+ readRawResources(join28(configDir, dirs.agentsDir))
249818
249880
  ]);
249819
249881
  return { entities, agents };
249820
249882
  }
249883
+ async function collectArtifacts(target) {
249884
+ const siteWorker = await collectSiteWorker(target.root);
249885
+ return {
249886
+ files: siteWorker ? [] : await collectBuildOutput(requireOutputDir(target)),
249887
+ ...siteWorker ? { siteWorker } : {},
249888
+ ...await collectResources(target.configDir, target)
249889
+ };
249890
+ }
249821
249891
  // src/core/version/gate.ts
249822
249892
  var VERSIONS_API_ENV = "BASE44_VERSIONS_API";
249823
249893
  function versionsApiEnabled(env = process.env) {
249824
249894
  const value = env[VERSIONS_API_ENV];
249825
249895
  return value === "1" || value === "true";
249826
249896
  }
249827
- // src/core/version/project.ts
249828
- import { dirname as dirname21, join as join28, resolve as resolve11 } from "node:path";
249829
- var DEFAULT_BUILD_COMMAND = "npm run build";
249830
- var DEFAULT_OUTPUT_DIRECTORY = "dist";
249831
- async function resolvePublishTarget(projectRoot, overrides = {}) {
249832
- const project = await readSettingsIfPresent(projectRoot);
249833
- const root = project?.root ?? projectRoot ?? process.cwd();
249834
- return {
249835
- root,
249836
- configDir: project ? dirname21(project.configPath) : join28(root, PROJECT_SUBDIR),
249837
- buildCommand: project ? project.site?.buildCommand : DEFAULT_BUILD_COMMAND,
249838
- outputDir: outputDirectory(project, root, overrides.outputDir),
249839
- entitiesDir: project?.entitiesDir ?? "entities",
249840
- agentsDir: project?.agentsDir ?? "agents"
249841
- };
249842
- }
249843
- function outputDirectory(project, root, override) {
249844
- const configured = override ?? (project ? project.site?.outputDirectory : DEFAULT_OUTPUT_DIRECTORY);
249845
- return configured ? resolve11(root, configured) : null;
249846
- }
249847
- function requireOutputDir(target) {
249848
- if (target.outputDir === null) {
249849
- throw new ConfigNotFoundError("No site configuration found.", {
249850
- hints: [
249851
- {
249852
- message: `Add 'site.outputDirectory' to your config.jsonc (e.g., "site": { "outputDirectory": "dist" })`
249853
- },
249854
- { message: `Or pass --output-dir <dir>, relative to ${target.root}` }
249855
- ]
249856
- });
249857
- }
249858
- return target.outputDir;
249859
- }
249860
- async function readSettingsIfPresent(projectRoot) {
249861
- try {
249862
- return await readProjectSettings(projectRoot);
249863
- } catch (error) {
249864
- if (error instanceof ConfigNotFoundError) {
249865
- return null;
249866
- }
249867
- throw error;
249868
- }
249869
- }
249870
249897
  // src/cli/commands/project/build.ts
249871
249898
  async function buildAction(ctx) {
249872
- const { app } = ctx;
249873
- const target = await resolvePublishTarget(app?.projectRoot);
249899
+ const app = requireApp(ctx);
249900
+ const target = await resolvePublishTarget(app.projectRoot);
249874
249901
  await runSiteBuild(ctx, {
249875
249902
  root: target.root,
249876
249903
  buildCommand: target.buildCommand,
249877
- appId: app?.id ?? ""
249904
+ appId: app.id
249878
249905
  });
249879
249906
  return {
249880
- outroMessage: `Site built with app id ${theme.styles.bold(app?.id ?? "")}`
249907
+ outroMessage: `Site built with app id ${theme.styles.bold(app.id)}`
249881
249908
  };
249882
249909
  }
249883
249910
  function getBuildCommand() {
@@ -250837,36 +250864,25 @@ function concurrencyOption() {
250837
250864
 
250838
250865
  // src/cli/commands/publish.ts
250839
250866
  async function publishAction(ctx, options) {
250840
- const { runTask, log, jsonMode, app } = ctx;
250841
- const target = await resolvePublishTarget(app?.projectRoot, {
250842
- outputDir: options.outputDir
250843
- });
250867
+ const { runTask, log, jsonMode } = ctx;
250868
+ const app = requireApp(ctx);
250869
+ const target = await tagStep("create_version", () => resolvePublishTarget(app.projectRoot, { outputDir: options.outputDir }));
250844
250870
  if (options.build !== false) {
250845
250871
  await tagStep("build", () => runSiteBuild(ctx, {
250846
250872
  root: target.root,
250847
250873
  buildCommand: target.buildCommand,
250848
- appId: app?.id ?? ""
250874
+ appId: app.id
250849
250875
  }));
250850
250876
  }
250851
250877
  const gitHash = await resolveProvenanceCommit(target.root, options.gitHash);
250852
250878
  const result = await runTask("Publishing...", async (updateMessage) => {
250853
- const artifacts = await tagStep("create_version", async () => {
250854
- const siteWorker = await collectSiteWorker(target.root);
250855
- const assetsDir = siteWorker ? siteWorker.assetsDir : requireOutputDir(target);
250856
- return {
250857
- files: assetsDir ? await collectBuildOutput(assetsDir, {
250858
- requireEntry: siteWorker === null
250859
- }) : [],
250860
- ...siteWorker ? { siteWorker } : {},
250861
- ...await collectResources(target.configDir, target)
250862
- };
250863
- });
250879
+ const artifacts = await tagStep("create_version", () => collectArtifacts(target));
250864
250880
  return await publishVersion(artifacts, {
250865
250881
  sourceCommit: gitHash,
250866
250882
  target: options.target,
250867
250883
  concurrency: options.concurrency,
250868
250884
  progress: {
250869
- onDeclared: ({ fileCount, owedFiles }) => updateMessage(`Uploading ${owedFiles} of ${fileCount} files`),
250885
+ onDeclared: ({ fileCount }) => updateMessage(`Uploading ${fileCount} files`),
250870
250886
  onUpload: ({ uploadedFiles, totalFiles }) => updateMessage(`Uploaded ${uploadedFiles} of ${totalFiles} files`)
250871
250887
  }
250872
250888
  });
@@ -251576,19 +251592,17 @@ function getTypesCommand() {
251576
251592
  }
251577
251593
 
251578
251594
  // src/cli/commands/versions/create.ts
251579
- async function createAction2({ runTask, jsonMode, app }, options) {
251580
- const target = await resolvePublishTarget(app?.projectRoot, {
251595
+ async function createAction2(ctx, options) {
251596
+ const { runTask, jsonMode } = ctx;
251597
+ const target = await resolvePublishTarget(requireApp(ctx).projectRoot, {
251581
251598
  outputDir: options.outputDir
251582
251599
  });
251583
251600
  const gitHash = await resolveProvenanceCommit(target.root, options.gitHash);
251584
- const version = await runTask("Creating version...", async (updateMessage) => await createVersion({
251585
- files: await collectBuildOutput(requireOutputDir(target)),
251586
- ...await collectResources(target.configDir, target)
251587
- }, {
251601
+ const version = await runTask("Creating version...", async (updateMessage) => await createVersion(await collectArtifacts(target), {
251588
251602
  sourceCommit: gitHash,
251589
251603
  concurrency: options.concurrency,
251590
251604
  progress: {
251591
- onDeclared: ({ fileCount, owedFiles }) => updateMessage(`Uploading ${owedFiles} of ${fileCount} files`),
251605
+ onDeclared: ({ fileCount }) => updateMessage(`Uploading ${fileCount} files`),
251592
251606
  onUpload: ({ uploadedFiles, totalFiles }) => updateMessage(`Uploaded ${uploadedFiles} of ${totalFiles} files`)
251593
251607
  }
251594
251608
  }), {
@@ -251622,7 +251636,7 @@ async function deployAction3({ runTask, jsonMode }, versionId, options) {
251622
251636
  };
251623
251637
  }
251624
251638
  function getVersionDeployCommand() {
251625
- return new Base44Command("deploy").description("Point an environment at an already-recorded version (also the rollback)").argument("<version-id>", "The version to serve").option("--target <name>", "Environment to point at it").action(deployAction3);
251639
+ return new Base44Command("deploy").description("Point an environment at an already-recorded version (also the rollback)").argument("<version-id>", "The version to serve").addOption(targetOption()).action(deployAction3);
251626
251640
  }
251627
251641
 
251628
251642
  // src/cli/commands/versions/index.ts
@@ -253953,11 +253967,11 @@ import { relative as relative9 } from "node:path";
253953
253967
  // ../../node_modules/chokidar/index.js
253954
253968
  import { EventEmitter as EventEmitter3 } from "node:events";
253955
253969
  import { stat as statcb, Stats } from "node:fs";
253956
- import { readdir as readdir3, stat as stat7 } from "node:fs/promises";
253970
+ import { readdir as readdir3, stat as stat6 } from "node:fs/promises";
253957
253971
  import * as sp3 from "node:path";
253958
253972
 
253959
253973
  // ../../node_modules/readdirp/index.js
253960
- import { lstat as lstat2, readdir as readdir2, realpath, stat as stat5 } from "node:fs/promises";
253974
+ import { lstat as lstat2, readdir as readdir2, realpath, stat as stat4 } from "node:fs/promises";
253961
253975
  import { join as pjoin, relative as prelative, resolve as presolve, sep as psep } from "node:path";
253962
253976
  import { Readable as Readable6 } from "node:stream";
253963
253977
  var EntryTypes = {
@@ -254039,7 +254053,7 @@ class ReaddirpStream extends Readable6 {
254039
254053
  const { root, type } = opts;
254040
254054
  this._fileFilter = normalizeFilter(opts.fileFilter);
254041
254055
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
254042
- const statMethod = opts.lstat ? lstat2 : stat5;
254056
+ const statMethod = opts.lstat ? lstat2 : stat4;
254043
254057
  if (wantBigintFsStats) {
254044
254058
  this._stat = (path) => statMethod(path, { bigint: true });
254045
254059
  } else {
@@ -254192,7 +254206,7 @@ function readdirp(root, options = {}) {
254192
254206
 
254193
254207
  // ../../node_modules/chokidar/handler.js
254194
254208
  import { watch as fs_watch, unwatchFile, watchFile } from "node:fs";
254195
- import { realpath as fsrealpath, lstat as lstat3, open as open2, stat as stat6 } from "node:fs/promises";
254209
+ import { realpath as fsrealpath, lstat as lstat3, open as open2, stat as stat5 } from "node:fs/promises";
254196
254210
  import { type as osType } from "node:os";
254197
254211
  import * as sp2 from "node:path";
254198
254212
  var STR_DATA = "data";
@@ -254218,7 +254232,7 @@ var EVENTS = {
254218
254232
  };
254219
254233
  var EV = EVENTS;
254220
254234
  var THROTTLE_MODE_WATCH = "watch";
254221
- var statMethods = { lstat: lstat3, stat: stat6 };
254235
+ var statMethods = { lstat: lstat3, stat: stat5 };
254222
254236
  var KEY_LISTENERS = "listeners";
254223
254237
  var KEY_ERR = "errHandlers";
254224
254238
  var KEY_RAW = "rawEmitters";
@@ -254689,7 +254703,7 @@ class NodeFsHandler {
254689
254703
  return;
254690
254704
  if (!newStats || newStats.mtimeMs === 0) {
254691
254705
  try {
254692
- const newStats = await stat6(file);
254706
+ const newStats = await stat5(file);
254693
254707
  if (this.fsw.closed)
254694
254708
  return;
254695
254709
  const at = newStats.atimeMs;
@@ -255361,7 +255375,7 @@ class FSWatcher extends EventEmitter3 {
255361
255375
  const fullPath = opts.cwd ? sp3.join(opts.cwd, path) : path;
255362
255376
  let stats;
255363
255377
  try {
255364
- stats = await stat7(fullPath);
255378
+ stats = await stat6(fullPath);
255365
255379
  } catch (err) {}
255366
255380
  if (!stats || this.closed)
255367
255381
  return;
@@ -258351,7 +258365,7 @@ class ReduceableCache {
258351
258365
  }
258352
258366
  }
258353
258367
  // ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
258354
- import { createReadStream as createReadStream4 } from "node:fs";
258368
+ import { createReadStream as createReadStream3 } from "node:fs";
258355
258369
  import { createInterface as createInterface2 } from "node:readline";
258356
258370
  var LRU_FILE_CONTENTS_CACHE = new ReduceableCache(25);
258357
258371
  var LRU_FILE_CONTENTS_FS_READ_FAILED = new ReduceableCache(20);
@@ -258395,7 +258409,7 @@ async function addSourceContext(frames) {
258395
258409
  }
258396
258410
  function getContextLinesFromFile(path, ranges, output) {
258397
258411
  return new Promise((resolve) => {
258398
- const stream = createReadStream4(path);
258412
+ const stream = createReadStream3(path);
258399
258413
  const lineReaded = createInterface2({
258400
258414
  input: stream
258401
258415
  });
@@ -260346,4 +260360,4 @@ export {
260346
260360
  runCLI
260347
260361
  };
260348
260362
 
260349
- //# debugId=6F5FA046DBD3D8D164756E2164756E21
260363
+ //# debugId=7059640A5E6CFF9564756E2164756E21