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

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,179 @@ 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
+ var KEYED_RETRY = {
247320
+ limit: 3,
247321
+ methods: ["patch"],
247322
+ statusCodes: [408, 500, 502, 503, 504],
247323
+ retryOnTimeout: true
247324
+ };
247325
+ async function patch(path, json, doing, retry) {
247326
+ try {
247327
+ return await getAppClient().patch(path, {
247328
+ json,
247329
+ timeout: 180000,
247330
+ ...retry ? { retry } : {}
247331
+ });
247332
+ } catch (error) {
247333
+ throw await ApiError.fromHttpError(error, doing);
247334
+ }
247335
+ }
247336
+ function parse10(schema, body, what) {
247337
+ const result = schema.safeParse(body);
247338
+ if (!result.success) {
247339
+ throw new SchemaValidationError(`Invalid ${what} response from server`, result.error);
247340
+ }
247341
+ return result.data;
247342
+ }
247343
+ async function createVersion(artifacts, options = {}) {
247344
+ const declared = parse10(DeclareVersionResponseSchema, await (await post("versions", {
247345
+ static_bundle: artifacts.files.map(declaredFile),
247346
+ ...artifacts.siteWorker ? {
247347
+ site_worker: {
247348
+ main: artifacts.siteWorker.main,
247349
+ modules: artifacts.siteWorker.modules.map(declaredModule),
247350
+ assets: artifacts.siteWorker.assets.map(declaredFile),
247351
+ compatibility_date: artifacts.siteWorker.compatibilityDate,
247352
+ compatibility_flags: artifacts.siteWorker.compatibilityFlags,
247353
+ assets_config: declaredAssetsConfig(artifacts.siteWorker.assetsConfig)
247354
+ }
247355
+ } : {},
247356
+ entities: artifacts.entities,
247357
+ agents: artifacts.agents,
247358
+ source_commit: options.sourceCommit
247359
+ }, "declaring a version")).json(), "declare");
247360
+ const declaredFiles = [
247361
+ ...artifacts.files,
247362
+ ...artifacts.siteWorker?.modules ?? [],
247363
+ ...artifacts.siteWorker?.assets ?? []
247364
+ ];
247365
+ options.progress?.onDeclared?.({ fileCount: declaredFiles.length });
247366
+ if (declared.uploads.length !== declaredFiles.length) {
247367
+ throw new InternalError(`Declared ${declaredFiles.length} files but the server signed ${declared.uploads.length} upload URLs.`);
247368
+ }
247369
+ const drifted = declared.uploads.findIndex((upload, index) => upload.path !== declaredFiles[index].path);
247370
+ if (drifted !== -1) {
247371
+ throw new InternalError(`Upload ${drifted} is signed for ${declared.uploads[drifted].path}, but that slot declared ${declaredFiles[drifted].path}.`);
247372
+ }
247373
+ let uploadedFiles = 0;
247374
+ await pMap(declared.uploads, async (upload, index) => {
247375
+ await putPresigned(upload, declaredFiles[index].absolutePath);
247376
+ uploadedFiles++;
247377
+ options.progress?.onUpload?.({
247378
+ uploadedFiles,
247379
+ totalFiles: declared.uploads.length
247380
+ });
247381
+ }, { concurrency: options.concurrency ?? DEFAULT_VERSION_UPLOAD_CONCURRENCY });
247382
+ return parse10(CreateVersionResponseSchema, await (await post(`versions/${encodeURIComponent(declared.sessionId)}/finalize`, {}, "creating a version")).json(), "create version");
247383
+ }
247384
+ async function setEnvironmentVersion(environment, versionId, options = {}) {
247385
+ return parse10(EnvironmentResponseSchema, await (await patch(`environments/${encodeURIComponent(environment)}`, {
247386
+ version_id: versionId,
247387
+ ...options.idempotencyKey ? { idempotency_key: options.idempotencyKey } : {}
247388
+ }, "setting the environment's version", options.idempotencyKey ? KEYED_RETRY : undefined)).json(), "environment");
247389
+ }
247390
+
247391
+ // src/core/version/publish.ts
247392
+ var STEP = Symbol.for("base44.publishStep");
247393
+ var DEFAULT_ENVIRONMENT = "production";
247394
+ async function tagStep(step, run) {
247395
+ try {
247396
+ return await run();
247397
+ } catch (error) {
247398
+ if (error !== null && typeof error === "object" && !(STEP in error) && Object.isExtensible(error)) {
247399
+ Object.defineProperty(error, STEP, { value: step, enumerable: false });
247400
+ }
247401
+ throw error;
247402
+ }
247403
+ }
247404
+ function stepOf(error) {
247405
+ return error !== null && typeof error === "object" && STEP in error ? error[STEP] : undefined;
247406
+ }
247407
+ async function publishVersion(artifacts, options = {}) {
247408
+ const version = await tagStep("create_version", () => createVersion(artifacts, {
247409
+ sourceCommit: options.sourceCommit,
247410
+ concurrency: options.concurrency,
247411
+ progress: options.progress
247412
+ }));
247413
+ const environment = await tagStep("deploy", () => setEnvironmentVersion(options.target ?? DEFAULT_ENVIRONMENT, version.versionId, {
247414
+ idempotencyKey: randomUUID4()
247415
+ }));
247416
+ return {
247417
+ environment: environment.name,
247418
+ versionId: environment.versionId,
247419
+ manifestHash: environment.manifestHash,
247420
+ deploymentId: environment.deploymentId
247421
+ };
247422
+ }
247423
+
247265
247424
  // src/cli/utils/command/Base44Command.ts
247266
247425
  function writeJsonSuccess(result) {
247267
247426
  if (result.stdout) {
@@ -249625,143 +249784,6 @@ async function maybeAskToBuild(isNonInteractive, buildCommand) {
249625
249784
  });
249626
249785
  return !Ct(answer) && answer;
249627
249786
  }
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
249787
  // src/core/version/artifacts.ts
249766
249788
  import { createHash as createHash2 } from "node:crypto";
249767
249789
  import { join as join28, resolve as resolve11 } from "node:path";
@@ -249902,28 +249924,6 @@ function versionsApiEnabled(env = process.env) {
249902
249924
  const value = env[VERSIONS_API_ENV];
249903
249925
  return value === "1" || value === "true";
249904
249926
  }
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
249927
  // src/cli/commands/project/build.ts
249928
249928
  async function buildAction(ctx) {
249929
249929
  const app = requireApp(ctx);
@@ -250896,9 +250896,9 @@ function concurrencyOption() {
250896
250896
  async function publishAction(ctx, options) {
250897
250897
  const { runTask, log, jsonMode } = ctx;
250898
250898
  const app = requireApp(ctx);
250899
- const target = await tagStep2("create_version", () => resolvePublishTarget(app.projectRoot, { outputDir: options.outputDir }));
250899
+ const target = await tagStep("create_version", () => resolvePublishTarget(app.projectRoot, { outputDir: options.outputDir }));
250900
250900
  if (options.build !== false) {
250901
- await tagStep2("build", () => runSiteBuild(ctx, {
250901
+ await tagStep("build", () => runSiteBuild(ctx, {
250902
250902
  root: target.root,
250903
250903
  buildCommand: target.buildCommand,
250904
250904
  appId: app.id
@@ -250906,7 +250906,7 @@ async function publishAction(ctx, options) {
250906
250906
  }
250907
250907
  const gitHash = await resolveProvenanceCommit(target.root, options.gitHash);
250908
250908
  const result = await runTask("Publishing...", async (updateMessage) => {
250909
- const artifacts = await tagStep2("create_version", () => collectArtifacts(target));
250909
+ const artifacts = await tagStep("create_version", () => collectArtifacts(target));
250910
250910
  return await publishVersion(artifacts, {
250911
250911
  sourceCommit: gitHash,
250912
250912
  target: options.target,
@@ -260406,4 +260406,4 @@ export {
260406
260406
  runCLI
260407
260407
  };
260408
260408
 
260409
- //# debugId=53C2F96B49B467E964756E2164756E21
260409
+ //# debugId=8F0A0C78488FF54F64756E2164756E21