@base44-preview/cli 0.1.7-pr.585.818cbdc → 0.1.7-pr.585.8ca1ebb

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
@@ -248113,6 +248113,7 @@ var package_default = {
248113
248113
  nanoid: "^5.1.6",
248114
248114
  open: "^11.0.0",
248115
248115
  outdent: "^0.8.0",
248116
+ "p-map": "^7.0.6",
248116
248117
  "p-wait-for": "^6.0.0",
248117
248118
  "posthog-node": "5.21.2",
248118
248119
  qs: "^6.12.3",
@@ -248361,12 +248362,6 @@ async function createArchive(pathToArchive, targetArchivePath) {
248361
248362
  cwd: pathToArchive
248362
248363
  }, ["."]);
248363
248364
  }
248364
- // src/core/site/gate.ts
248365
- var STATIC_DEPLOYMENTS_ENV = "BASE44_STATIC_DEPLOYMENTS";
248366
- function staticDeploymentsEnabled(env2 = process.env) {
248367
- const value = env2[STATIC_DEPLOYMENTS_ENV];
248368
- return value === "1" || value === "true";
248369
- }
248370
248365
  // src/core/site/manifest.ts
248371
248366
  import { createHash } from "node:crypto";
248372
248367
  import { readFile as readFile2, stat } from "node:fs/promises";
@@ -248415,66 +248410,172 @@ async function buildAssetManifest(assetsDir, appId) {
248415
248410
  import { readFile as readFile4 } from "node:fs/promises";
248416
248411
  import { join as join16 } from "node:path";
248417
248412
 
248418
- // src/core/utils/git.ts
248419
- var GIT_HASH_PATTERN = /^[a-fA-F0-9]{7,64}$/;
248420
- function isGitCommitHash(value) {
248421
- return GIT_HASH_PATTERN.test(value);
248413
+ // src/core/site/upload.ts
248414
+ import { readFile as readFile3 } from "node:fs/promises";
248415
+
248416
+ // ../../node_modules/p-map/index.js
248417
+ async function pMap(iterable, mapper, {
248418
+ concurrency = Number.POSITIVE_INFINITY,
248419
+ stopOnError = true,
248420
+ signal
248421
+ } = {}) {
248422
+ return new Promise((resolve_, reject_) => {
248423
+ if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
248424
+ throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
248425
+ }
248426
+ if (typeof mapper !== "function") {
248427
+ throw new TypeError("Mapper function is required");
248428
+ }
248429
+ if (!(Number.isSafeInteger(concurrency) && concurrency >= 1 || concurrency === Number.POSITIVE_INFINITY)) {
248430
+ throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
248431
+ }
248432
+ const result = [];
248433
+ const errors4 = [];
248434
+ const skippedIndexesMap = new Map;
248435
+ let isRejected = false;
248436
+ let isResolved = false;
248437
+ let isIterableDone = false;
248438
+ let resolvingCount = 0;
248439
+ let currentIndex = 0;
248440
+ const iterator = iterable[Symbol.iterator] === undefined ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
248441
+ const signalListener = () => {
248442
+ reject(signal.reason);
248443
+ };
248444
+ const cleanup = () => {
248445
+ signal?.removeEventListener("abort", signalListener);
248446
+ };
248447
+ const resolve3 = (value) => {
248448
+ resolve_(value);
248449
+ cleanup();
248450
+ };
248451
+ const reject = (reason) => {
248452
+ isRejected = true;
248453
+ isResolved = true;
248454
+ reject_(reason);
248455
+ cleanup();
248456
+ };
248457
+ if (signal) {
248458
+ if (signal.aborted) {
248459
+ reject(signal.reason);
248460
+ return;
248461
+ }
248462
+ signal.addEventListener("abort", signalListener, { once: true });
248463
+ }
248464
+ const next = async () => {
248465
+ if (isResolved) {
248466
+ return;
248467
+ }
248468
+ const nextItem = await iterator.next();
248469
+ const index = currentIndex;
248470
+ currentIndex++;
248471
+ if (nextItem.done) {
248472
+ isIterableDone = true;
248473
+ if (resolvingCount === 0 && !isResolved) {
248474
+ if (!stopOnError && errors4.length > 0) {
248475
+ reject(new AggregateError(errors4));
248476
+ return;
248477
+ }
248478
+ isResolved = true;
248479
+ if (skippedIndexesMap.size === 0) {
248480
+ resolve3(result);
248481
+ return;
248482
+ }
248483
+ const pureResult = [];
248484
+ for (const [index2, value] of result.entries()) {
248485
+ if (skippedIndexesMap.get(index2) === pMapSkip) {
248486
+ continue;
248487
+ }
248488
+ pureResult.push(value);
248489
+ }
248490
+ resolve3(pureResult);
248491
+ }
248492
+ return;
248493
+ }
248494
+ resolvingCount++;
248495
+ (async () => {
248496
+ try {
248497
+ const element = await nextItem.value;
248498
+ if (isResolved) {
248499
+ return;
248500
+ }
248501
+ const value = await mapper(element, index);
248502
+ if (value === pMapSkip) {
248503
+ skippedIndexesMap.set(index, value);
248504
+ }
248505
+ result[index] = value;
248506
+ resolvingCount--;
248507
+ await next();
248508
+ } catch (error48) {
248509
+ if (stopOnError) {
248510
+ reject(error48);
248511
+ } else {
248512
+ errors4.push(error48);
248513
+ resolvingCount--;
248514
+ try {
248515
+ await next();
248516
+ } catch (error49) {
248517
+ reject(error49);
248518
+ }
248519
+ }
248520
+ }
248521
+ })();
248522
+ };
248523
+ (async () => {
248524
+ for (let index = 0;index < concurrency; index++) {
248525
+ try {
248526
+ await next();
248527
+ } catch (error48) {
248528
+ reject(error48);
248529
+ break;
248530
+ }
248531
+ if (isIterableDone || isRejected) {
248532
+ break;
248533
+ }
248534
+ }
248535
+ })();
248536
+ });
248422
248537
  }
248538
+ var pMapSkip = Symbol("skip");
248423
248539
 
248424
248540
  // src/core/site/upload.ts
248425
- import { readFile as readFile3 } from "node:fs/promises";
248426
- var UPLOAD_CONCURRENCY = 3;
248427
- var MAX_ATTEMPTS_PER_UPLOAD = 3;
248541
+ var DEFAULT_UPLOAD_CONCURRENCY = 3;
248542
+ var MAX_UPLOAD_CONCURRENCY = 50;
248543
+ var MAX_UPLOAD_ATTEMPTS = 3;
248428
248544
  var RETRY_BASE_DELAY_MS = 500;
248429
- async function uploadPresignedAssets(uploads, assets, onProgress) {
248545
+ async function uploadPresignedAssets(uploads, assets, options = {}) {
248546
+ const { concurrency = DEFAULT_UPLOAD_CONCURRENCY, onProgress } = options;
248430
248547
  let uploadedFiles = 0;
248431
- let nextUpload = 0;
248432
- const worker = async () => {
248433
- while (nextUpload < uploads.length) {
248434
- const upload = uploads[nextUpload++];
248435
- await uploadPresignedAssetWithRetry(upload, assets);
248436
- uploadedFiles++;
248437
- onProgress?.({ uploadedFiles, totalFiles: uploads.length });
248438
- }
248439
- };
248440
- await Promise.all(Array.from({ length: Math.min(UPLOAD_CONCURRENCY, uploads.length) }, worker));
248548
+ await pMap(uploads, async (upload) => {
248549
+ await uploadPresignedAsset(upload, assets);
248550
+ uploadedFiles++;
248551
+ onProgress?.({ uploadedFiles, totalFiles: uploads.length });
248552
+ }, { concurrency });
248441
248553
  }
248442
- async function uploadPresignedAssetWithRetry(upload, assets) {
248554
+ async function uploadPresignedAsset(upload, assets) {
248443
248555
  const entry = assets.manifest[upload.path];
248444
248556
  const file2 = entry && assets.filesByHash.get(entry.hash);
248445
248557
  if (!file2) {
248446
248558
  throw new InternalError(`Server requested upload of unknown asset path: ${upload.path}`);
248447
248559
  }
248448
248560
  const content = await readFile3(file2.absolutePath);
248449
- let lastError;
248450
- for (let attempt = 0;attempt < MAX_ATTEMPTS_PER_UPLOAD; attempt++) {
248451
- if (attempt > 0) {
248452
- await sleep3(RETRY_BASE_DELAY_MS * 2 ** (attempt - 1));
248453
- }
248454
- try {
248455
- await distribution_default.put(upload.url, {
248456
- body: new Uint8Array(content),
248457
- headers: { "Content-Type": upload.contentType },
248458
- timeout: 120000,
248459
- retry: 0
248460
- });
248461
- return;
248462
- } catch (error48) {
248463
- lastError = error48;
248464
- }
248561
+ try {
248562
+ await distribution_default.put(upload.url, {
248563
+ body: new Uint8Array(content),
248564
+ headers: { "Content-Type": upload.contentType },
248565
+ timeout: 120000,
248566
+ retry: {
248567
+ limit: MAX_UPLOAD_ATTEMPTS - 1,
248568
+ delay: (attempt) => RETRY_BASE_DELAY_MS * 2 ** (attempt - 1)
248569
+ }
248570
+ });
248571
+ } catch (error48) {
248572
+ throw await ApiError.fromHttpError(error48, "uploading static assets");
248465
248573
  }
248466
- throw await ApiError.fromHttpError(lastError, "uploading static assets");
248467
- }
248468
- function sleep3(ms) {
248469
- return new Promise((resolve3) => setTimeout(resolve3, ms));
248470
248574
  }
248471
248575
 
248472
248576
  // src/core/site/static-site.ts
248473
248577
  async function deployStaticSite(options) {
248474
- const { outputDir, gitHash, progress } = options;
248475
- if (!isGitCommitHash(gitHash)) {
248476
- throw new InvalidInputError(`'${gitHash}' is not a git commit hash.`);
248477
- }
248578
+ const { outputDir, gitHash, concurrency, progress } = options;
248478
248579
  const assets = await buildAssetManifest(outputDir, getAppContext().id);
248479
248580
  if (!assets.manifest["/index.html"]) {
248480
248581
  throw new InvalidInputError(`No index.html found in "${outputDir}" — a static site needs one at the output directory root.`);
@@ -248488,7 +248589,10 @@ async function deployStaticSite(options) {
248488
248589
  newAssets: created.assetUploads?.uploads.length ?? 0
248489
248590
  });
248490
248591
  if (created.assetUploads) {
248491
- await uploadPresignedAssets(created.assetUploads.uploads, assets, progress?.onAssetUpload);
248592
+ await uploadPresignedAssets(created.assetUploads.uploads, assets, {
248593
+ concurrency,
248594
+ onProgress: progress?.onAssetUpload
248595
+ });
248492
248596
  }
248493
248597
  const indexHtml = await readFile4(join16(outputDir, "index.html"));
248494
248598
  const finalized = await finalizeStaticDeployment(created.deploymentId, new Uint8Array(indexHtml));
@@ -255716,6 +255820,11 @@ function verifyDenoInstalled(context) {
255716
255820
  });
255717
255821
  }
255718
255822
  }
255823
+ // src/core/utils/git.ts
255824
+ var GIT_HASH_PATTERN = /^[a-fA-F0-9]{7,64}$/;
255825
+ function isGitCommitHash(value) {
255826
+ return GIT_HASH_PATTERN.test(value);
255827
+ }
255719
255828
  // src/core/workspace/schema.ts
255720
255829
  var WorkspaceSchema = exports_external.object({
255721
255830
  id: exports_external.string(),
@@ -258940,13 +259049,15 @@ async function deployAction2(ctx, options) {
258940
259049
  }
258941
259050
  await maybeBuildBeforeDeploy(ctx, project2, options.build);
258942
259051
  const outputDir = resolve11(project2.root, outputDirectory);
258943
- return options.gitHash ? await deployToDeploymentsApi(ctx, outputDir, options.gitHash) : await deployTarball(ctx, outputDir);
259052
+ const { gitHash, concurrency } = options;
259053
+ return gitHash ? await deployToDeploymentsApi(ctx, outputDir, gitHash, concurrency) : await deployTarball(ctx, outputDir);
258944
259054
  }
258945
- async function deployToDeploymentsApi({ runTask: runTask2, log, jsonMode }, outputDir, gitHash) {
259055
+ async function deployToDeploymentsApi({ runTask: runTask2, log, jsonMode }, outputDir, gitHash, concurrency) {
258946
259056
  const progressLines = [];
258947
259057
  const { deploymentId } = await runTask2("Deploying site...", async (updateMessage) => await deployStaticSite({
258948
259058
  outputDir,
258949
259059
  gitHash,
259060
+ concurrency,
258950
259061
  progress: {
258951
259062
  onAssets: ({ totalAssets, newAssets }) => {
258952
259063
  const line = `Found ${totalAssets} static assets (${newAssets} new)`;
@@ -258977,10 +259088,27 @@ async function deployTarball({ runTask: runTask2 }, outputDir) {
258977
259088
  function getSiteDeployCommand() {
258978
259089
  const command2 = new Base44Command("deploy").description("Deploy built site files to Base44 hosting").option("-y, --yes", "Skip confirmation prompt").option("--build", "Build the site before deploying (skips the prompt)").option("--no-build", "Deploy without building (skips the prompt)");
258979
259090
  if (staticDeploymentsEnabled()) {
258980
- command2.addOption(new Option("--git-hash <hash>", "Commit the build came from — deploys through the deployments API"));
259091
+ command2.addOption(new Option("--git-hash <hash>", "Commit the build came from — deploys through the deployments API").argParser((value) => {
259092
+ if (!isGitCommitHash(value)) {
259093
+ throw new InvalidArgumentError("Expected a git commit hash (7-64 hex chars).");
259094
+ }
259095
+ return value;
259096
+ }));
259097
+ command2.addOption(new Option("--concurrency <n>", "Parallel asset uploads").default(DEFAULT_UPLOAD_CONCURRENCY).argParser(parseConcurrency));
258981
259098
  }
258982
259099
  return command2.action(deployAction2);
258983
259100
  }
259101
+ function parseConcurrency(value) {
259102
+ const parsed = Number(value);
259103
+ if (!Number.isInteger(parsed) || parsed < 1 || parsed > MAX_UPLOAD_CONCURRENCY) {
259104
+ throw new InvalidArgumentError(`Expected a whole number between 1 and ${MAX_UPLOAD_CONCURRENCY}.`);
259105
+ }
259106
+ return parsed;
259107
+ }
259108
+ function staticDeploymentsEnabled(env3 = process.env) {
259109
+ const value = env3["BASE44_STATIC_DEPLOYMENTS"];
259110
+ return value === "1" || value === "true";
259111
+ }
258984
259112
 
258985
259113
  // src/cli/commands/site/open.ts
258986
259114
  async function openAction({
@@ -267773,4 +267901,4 @@ export {
267773
267901
  CLIExitError
267774
267902
  };
267775
267903
 
267776
- //# debugId=7E09388401C6A22064756E2164756E21
267904
+ //# debugId=93B51FE0D9C7A0D764756E2164756E21