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

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,20 +228657,6 @@ 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
- }
228674
228660
 
228675
228661
  // src/core/utils/fs.ts
228676
228662
  async function pathExists(path) {
@@ -247262,6 +247248,169 @@ async function resolveBranchName(name) {
247262
247248
  return matches[0].id;
247263
247249
  }
247264
247250
 
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
+
247265
247414
  // src/cli/utils/command/Base44Command.ts
247266
247415
  function writeJsonSuccess(result) {
247267
247416
  if (result.stdout) {
@@ -249625,143 +249774,6 @@ async function maybeAskToBuild(isNonInteractive, buildCommand) {
249625
249774
  });
249626
249775
  return !Ct(answer) && answer;
249627
249776
  }
249628
-
249629
- // src/core/version/schema.ts
249630
- var DeclareVersionResponseSchema = object({
249631
- session_id: string2(),
249632
- uploads: array(object({
249633
- path: string2(),
249634
- url: string2(),
249635
- content_type: string2(),
249636
- content_length: number2(),
249637
- checksum_sha256: string2()
249638
- }))
249639
- }).transform((data) => ({
249640
- sessionId: data.session_id,
249641
- uploads: data.uploads.map((upload) => ({
249642
- path: upload.path,
249643
- url: upload.url,
249644
- contentType: upload.content_type,
249645
- contentLength: upload.content_length,
249646
- checksumSha256: upload.checksum_sha256
249647
- }))
249648
- }));
249649
- var CreateVersionResponseSchema = object({
249650
- version_id: string2(),
249651
- manifest_hash: string2()
249652
- }).transform((data) => ({
249653
- versionId: data.version_id,
249654
- manifestHash: data.manifest_hash
249655
- }));
249656
- var EnvironmentResponseSchema = object({
249657
- name: string2(),
249658
- version_id: string2(),
249659
- manifest_hash: string2(),
249660
- deployment_id: string2()
249661
- }).transform((data) => ({
249662
- name: data.name,
249663
- versionId: data.version_id,
249664
- manifestHash: data.manifest_hash,
249665
- deploymentId: data.deployment_id
249666
- }));
249667
-
249668
- // src/core/version/api.ts
249669
- var DEFAULT_VERSION_UPLOAD_CONCURRENCY = 8;
249670
- var MAX_VERSION_UPLOAD_CONCURRENCY = 16;
249671
- function declaredFile({ path, size, digest }) {
249672
- return { path, size, digest };
249673
- }
249674
- function declaredModule(module) {
249675
- return { ...declaredFile(module), type: module.type };
249676
- }
249677
- function declaredAssetsConfig(config) {
249678
- const stated = {
249679
- html_handling: config?.htmlHandling ?? null,
249680
- not_found_handling: config?.notFoundHandling ?? null,
249681
- run_worker_first: config?.runWorkerFirst ?? null,
249682
- headers: config?.headers ?? null,
249683
- redirects: config?.redirects ?? null
249684
- };
249685
- return Object.values(stated).every((v) => v === null) ? null : stated;
249686
- }
249687
- async function post(path, json, doing) {
249688
- try {
249689
- return await getAppClient().post(path, { json, timeout: 180000 });
249690
- } catch (error) {
249691
- throw await ApiError.fromHttpError(error, doing);
249692
- }
249693
- }
249694
- var KEYED_RETRY = {
249695
- limit: 3,
249696
- methods: ["patch"],
249697
- statusCodes: [408, 500, 502, 503, 504],
249698
- retryOnTimeout: true
249699
- };
249700
- async function patch(path, json, doing, retry) {
249701
- try {
249702
- return await getAppClient().patch(path, {
249703
- json,
249704
- timeout: 180000,
249705
- ...retry ? { retry } : {}
249706
- });
249707
- } catch (error) {
249708
- throw await ApiError.fromHttpError(error, doing);
249709
- }
249710
- }
249711
- function parse10(schema, body, what) {
249712
- const result = schema.safeParse(body);
249713
- if (!result.success) {
249714
- throw new SchemaValidationError(`Invalid ${what} response from server`, result.error);
249715
- }
249716
- return result.data;
249717
- }
249718
- async function createVersion(artifacts, options = {}) {
249719
- const declared = parse10(DeclareVersionResponseSchema, await (await post("versions", {
249720
- static_bundle: artifacts.files.map(declaredFile),
249721
- ...artifacts.siteWorker ? {
249722
- site_worker: {
249723
- main: artifacts.siteWorker.main,
249724
- modules: artifacts.siteWorker.modules.map(declaredModule),
249725
- assets: artifacts.siteWorker.assets.map(declaredFile),
249726
- compatibility_date: artifacts.siteWorker.compatibilityDate,
249727
- compatibility_flags: artifacts.siteWorker.compatibilityFlags,
249728
- assets_config: declaredAssetsConfig(artifacts.siteWorker.assetsConfig)
249729
- }
249730
- } : {},
249731
- entities: artifacts.entities,
249732
- agents: artifacts.agents,
249733
- source_commit: options.sourceCommit
249734
- }, "declaring a version")).json(), "declare");
249735
- const declaredFiles = [
249736
- ...artifacts.files,
249737
- ...artifacts.siteWorker?.modules ?? [],
249738
- ...artifacts.siteWorker?.assets ?? []
249739
- ];
249740
- options.progress?.onDeclared?.({ fileCount: declaredFiles.length });
249741
- if (declared.uploads.length !== declaredFiles.length) {
249742
- throw new InternalError(`Declared ${declaredFiles.length} files but the server signed ${declared.uploads.length} upload URLs.`);
249743
- }
249744
- const drifted = declared.uploads.findIndex((upload, index) => upload.path !== declaredFiles[index].path);
249745
- if (drifted !== -1) {
249746
- throw new InternalError(`Upload ${drifted} is signed for ${declared.uploads[drifted].path}, but that slot declared ${declaredFiles[drifted].path}.`);
249747
- }
249748
- let uploadedFiles = 0;
249749
- await pMap(declared.uploads, async (upload, index) => {
249750
- await putPresigned(upload, declaredFiles[index].absolutePath);
249751
- uploadedFiles++;
249752
- options.progress?.onUpload?.({
249753
- uploadedFiles,
249754
- totalFiles: declared.uploads.length
249755
- });
249756
- }, { concurrency: options.concurrency ?? DEFAULT_VERSION_UPLOAD_CONCURRENCY });
249757
- return parse10(CreateVersionResponseSchema, await (await post(`versions/${encodeURIComponent(declared.sessionId)}/finalize`, {}, "creating a version")).json(), "create version");
249758
- }
249759
- async function setEnvironmentVersion(environment, versionId, options = {}) {
249760
- return parse10(EnvironmentResponseSchema, await (await patch(`environments/${encodeURIComponent(environment)}`, {
249761
- version_id: versionId,
249762
- ...options.idempotencyKey ? { idempotency_key: options.idempotencyKey } : {}
249763
- }, "setting the environment's version", options.idempotencyKey ? KEYED_RETRY : undefined)).json(), "environment");
249764
- }
249765
249777
  // src/core/version/artifacts.ts
249766
249778
  import { createHash as createHash2 } from "node:crypto";
249767
249779
  import { join as join28, resolve as resolve11 } from "node:path";
@@ -249820,20 +249832,18 @@ async function digestFile(absolutePath) {
249820
249832
  }
249821
249833
  async function collectBuildOutput(outputDir, options = {}) {
249822
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
+ }
249823
249842
  if (found.length > MAX_FILE_COUNT) {
249824
249843
  throw new InvalidInputError(`Too many files: found ${found.length}, the limit is ${MAX_FILE_COUNT}.`);
249825
249844
  }
249826
- if (options.entryFile) {
249827
- if (found.length === 0) {
249828
- throw new InvalidInputError(`No files found in ${outputDir}. Build the site before creating a version.`, {
249829
- hints: [
249830
- { message: "Run 'base44 build' first", command: "base44 build" }
249831
- ]
249832
- });
249833
- }
249834
- if (!found.some((f) => f.path === options.entryFile)) {
249835
- throw new InvalidInputError(`${outputDir} has no ${options.entryFile}, so nothing could enter the site.`);
249836
- }
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.`);
249837
249847
  }
249838
249848
  return await pMap(found, async (file) => ({ ...file, digest: await digestFile(file.absolutePath) }), { concurrency: HASH_CONCURRENCY });
249839
249849
  }
@@ -249857,7 +249867,7 @@ async function collectSiteWorker(projectRoot) {
249857
249867
  digest: await digestFile(absolutePath),
249858
249868
  type
249859
249869
  }), { concurrency: HASH_CONCURRENCY }),
249860
- assets: assetsDir ? await collectBuildOutput(assetsDir) : [],
249870
+ assets: assetsDir ? await collectBuildOutput(assetsDir, { requireEntry: false }) : [],
249861
249871
  compatibilityDate: config.compatibilityDate,
249862
249872
  compatibilityFlags: config.compatibilityFlags,
249863
249873
  assetsConfig: config.assetsConfig
@@ -249889,9 +249899,7 @@ async function collectResources(configDir, dirs) {
249889
249899
  async function collectArtifacts(target) {
249890
249900
  const siteWorker = await collectSiteWorker(target.root);
249891
249901
  return {
249892
- files: siteWorker ? [] : await collectBuildOutput(requireOutputDir(target), {
249893
- entryFile: ENTRY2
249894
- }),
249902
+ files: siteWorker ? [] : await collectBuildOutput(requireOutputDir(target)),
249895
249903
  ...siteWorker ? { siteWorker } : {},
249896
249904
  ...await collectResources(target.configDir, target)
249897
249905
  };
@@ -249902,28 +249910,6 @@ function versionsApiEnabled(env = process.env) {
249902
249910
  const value = env[VERSIONS_API_ENV];
249903
249911
  return value === "1" || value === "true";
249904
249912
  }
249905
- // src/core/version/publish.ts
249906
- import { randomUUID as randomUUID4 } from "node:crypto";
249907
- var DEFAULT_ENVIRONMENT = "production";
249908
- async function tagStep2(step, run) {
249909
- return await tagStep(step, run);
249910
- }
249911
- async function publishVersion(artifacts, options = {}) {
249912
- const version = await tagStep2("create_version", () => createVersion(artifacts, {
249913
- sourceCommit: options.sourceCommit,
249914
- concurrency: options.concurrency,
249915
- progress: options.progress
249916
- }));
249917
- const environment = await tagStep2("deploy", () => setEnvironmentVersion(options.target ?? DEFAULT_ENVIRONMENT, version.versionId, {
249918
- idempotencyKey: randomUUID4()
249919
- }));
249920
- return {
249921
- environment: environment.name,
249922
- versionId: environment.versionId,
249923
- manifestHash: environment.manifestHash,
249924
- deploymentId: environment.deploymentId
249925
- };
249926
- }
249927
249913
  // src/cli/commands/project/build.ts
249928
249914
  async function buildAction(ctx) {
249929
249915
  const app = requireApp(ctx);
@@ -250896,9 +250882,9 @@ function concurrencyOption() {
250896
250882
  async function publishAction(ctx, options) {
250897
250883
  const { runTask, log, jsonMode } = ctx;
250898
250884
  const app = requireApp(ctx);
250899
- const target = await tagStep2("create_version", () => resolvePublishTarget(app.projectRoot, { outputDir: options.outputDir }));
250885
+ const target = await tagStep("create_version", () => resolvePublishTarget(app.projectRoot, { outputDir: options.outputDir }));
250900
250886
  if (options.build !== false) {
250901
- await tagStep2("build", () => runSiteBuild(ctx, {
250887
+ await tagStep("build", () => runSiteBuild(ctx, {
250902
250888
  root: target.root,
250903
250889
  buildCommand: target.buildCommand,
250904
250890
  appId: app.id
@@ -250906,7 +250892,7 @@ async function publishAction(ctx, options) {
250906
250892
  }
250907
250893
  const gitHash = await resolveProvenanceCommit(target.root, options.gitHash);
250908
250894
  const result = await runTask("Publishing...", async (updateMessage) => {
250909
- const artifacts = await tagStep2("create_version", () => collectArtifacts(target));
250895
+ const artifacts = await tagStep("create_version", () => collectArtifacts(target));
250910
250896
  return await publishVersion(artifacts, {
250911
250897
  sourceCommit: gitHash,
250912
250898
  target: options.target,
@@ -260406,4 +260392,4 @@ export {
260406
260392
  runCLI
260407
260393
  };
260408
260394
 
260409
- //# debugId=53C2F96B49B467E964756E2164756E21
260395
+ //# debugId=45EEED102FF0084464756E2164756E21