@base44-preview/cli 0.1.16-pr.626.51eb442 → 0.1.16-pr.626.891bf00

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