@base44-preview/cli 0.1.7-pr.585.85db235 → 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";
@@ -248417,55 +248412,170 @@ import { join as join16 } from "node:path";
248417
248412
 
248418
248413
  // src/core/site/upload.ts
248419
248414
  import { readFile as readFile3 } from "node:fs/promises";
248420
- var UPLOAD_CONCURRENCY = 3;
248421
- var MAX_ATTEMPTS_PER_UPLOAD = 3;
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
+ });
248537
+ }
248538
+ var pMapSkip = Symbol("skip");
248539
+
248540
+ // src/core/site/upload.ts
248541
+ var DEFAULT_UPLOAD_CONCURRENCY = 3;
248542
+ var MAX_UPLOAD_CONCURRENCY = 50;
248543
+ var MAX_UPLOAD_ATTEMPTS = 3;
248422
248544
  var RETRY_BASE_DELAY_MS = 500;
248423
- async function uploadPresignedAssets(uploads, assets, onProgress) {
248545
+ async function uploadPresignedAssets(uploads, assets, options = {}) {
248546
+ const { concurrency = DEFAULT_UPLOAD_CONCURRENCY, onProgress } = options;
248424
248547
  let uploadedFiles = 0;
248425
- let nextUpload = 0;
248426
- const worker = async () => {
248427
- while (nextUpload < uploads.length) {
248428
- const upload = uploads[nextUpload++];
248429
- await uploadPresignedAssetWithRetry(upload, assets);
248430
- uploadedFiles++;
248431
- onProgress?.({ uploadedFiles, totalFiles: uploads.length });
248432
- }
248433
- };
248434
- 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 });
248435
248553
  }
248436
- async function uploadPresignedAssetWithRetry(upload, assets) {
248554
+ async function uploadPresignedAsset(upload, assets) {
248437
248555
  const entry = assets.manifest[upload.path];
248438
248556
  const file2 = entry && assets.filesByHash.get(entry.hash);
248439
248557
  if (!file2) {
248440
248558
  throw new InternalError(`Server requested upload of unknown asset path: ${upload.path}`);
248441
248559
  }
248442
248560
  const content = await readFile3(file2.absolutePath);
248443
- let lastError;
248444
- for (let attempt = 0;attempt < MAX_ATTEMPTS_PER_UPLOAD; attempt++) {
248445
- if (attempt > 0) {
248446
- await sleep3(RETRY_BASE_DELAY_MS * 2 ** (attempt - 1));
248447
- }
248448
- try {
248449
- await distribution_default.put(upload.url, {
248450
- body: new Uint8Array(content),
248451
- headers: { "Content-Type": upload.contentType },
248452
- timeout: 120000,
248453
- retry: 0
248454
- });
248455
- return;
248456
- } catch (error48) {
248457
- lastError = error48;
248458
- }
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");
248459
248573
  }
248460
- throw await ApiError.fromHttpError(lastError, "uploading static assets");
248461
- }
248462
- function sleep3(ms) {
248463
- return new Promise((resolve3) => setTimeout(resolve3, ms));
248464
248574
  }
248465
248575
 
248466
248576
  // src/core/site/static-site.ts
248467
248577
  async function deployStaticSite(options) {
248468
- const { outputDir, gitHash, progress } = options;
248578
+ const { outputDir, gitHash, concurrency, progress } = options;
248469
248579
  const assets = await buildAssetManifest(outputDir, getAppContext().id);
248470
248580
  if (!assets.manifest["/index.html"]) {
248471
248581
  throw new InvalidInputError(`No index.html found in "${outputDir}" — a static site needs one at the output directory root.`);
@@ -248479,7 +248589,10 @@ async function deployStaticSite(options) {
248479
248589
  newAssets: created.assetUploads?.uploads.length ?? 0
248480
248590
  });
248481
248591
  if (created.assetUploads) {
248482
- await uploadPresignedAssets(created.assetUploads.uploads, assets, progress?.onAssetUpload);
248592
+ await uploadPresignedAssets(created.assetUploads.uploads, assets, {
248593
+ concurrency,
248594
+ onProgress: progress?.onAssetUpload
248595
+ });
248483
248596
  }
248484
248597
  const indexHtml = await readFile4(join16(outputDir, "index.html"));
248485
248598
  const finalized = await finalizeStaticDeployment(created.deploymentId, new Uint8Array(indexHtml));
@@ -258936,13 +259049,15 @@ async function deployAction2(ctx, options) {
258936
259049
  }
258937
259050
  await maybeBuildBeforeDeploy(ctx, project2, options.build);
258938
259051
  const outputDir = resolve11(project2.root, outputDirectory);
258939
- 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);
258940
259054
  }
258941
- async function deployToDeploymentsApi({ runTask: runTask2, log, jsonMode }, outputDir, gitHash) {
259055
+ async function deployToDeploymentsApi({ runTask: runTask2, log, jsonMode }, outputDir, gitHash, concurrency) {
258942
259056
  const progressLines = [];
258943
259057
  const { deploymentId } = await runTask2("Deploying site...", async (updateMessage) => await deployStaticSite({
258944
259058
  outputDir,
258945
259059
  gitHash,
259060
+ concurrency,
258946
259061
  progress: {
258947
259062
  onAssets: ({ totalAssets, newAssets }) => {
258948
259063
  const line = `Found ${totalAssets} static assets (${newAssets} new)`;
@@ -258979,9 +259094,21 @@ function getSiteDeployCommand() {
258979
259094
  }
258980
259095
  return value;
258981
259096
  }));
259097
+ command2.addOption(new Option("--concurrency <n>", "Parallel asset uploads").default(DEFAULT_UPLOAD_CONCURRENCY).argParser(parseConcurrency));
258982
259098
  }
258983
259099
  return command2.action(deployAction2);
258984
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
+ }
258985
259112
 
258986
259113
  // src/cli/commands/site/open.ts
258987
259114
  async function openAction({
@@ -267774,4 +267901,4 @@ export {
267774
267901
  CLIExitError
267775
267902
  };
267776
267903
 
267777
- //# debugId=54C8BB5F436D9BDE64756E2164756E21
267904
+ //# debugId=93B51FE0D9C7A0D764756E2164756E21