@base44-preview/cli 0.1.15-pr.626.454d562 → 0.1.15-pr.626.6dabe64

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
@@ -247338,13 +247338,14 @@ async function createVersion(artifacts, options = {}) {
247338
247338
  ...artifacts.siteWorker?.modules ?? [],
247339
247339
  ...artifacts.siteWorker?.assets ?? []
247340
247340
  ];
247341
- options.progress?.onDeclared?.({
247342
- fileCount: declaredFiles.length,
247343
- owedFiles: declared.uploads.length
247344
- });
247341
+ options.progress?.onDeclared?.({ fileCount: declaredFiles.length });
247345
247342
  if (declared.uploads.length !== declaredFiles.length) {
247346
247343
  throw new InternalError(`Declared ${declaredFiles.length} files but the server signed ${declared.uploads.length} upload URLs.`);
247347
247344
  }
247345
+ const drifted = declared.uploads.findIndex((upload, index) => upload.path !== declaredFiles[index].path);
247346
+ if (drifted !== -1) {
247347
+ throw new InternalError(`Upload ${drifted} is signed for ${declared.uploads[drifted].path}, but that slot declared ${declaredFiles[drifted].path}.`);
247348
+ }
247348
247349
  let uploadedFiles = 0;
247349
247350
  await pMap(declared.uploads, async (upload, index) => {
247350
247351
  await putPresigned(upload, declaredFiles[index].absolutePath);
@@ -247370,7 +247371,7 @@ async function tagStep(step, run) {
247370
247371
  try {
247371
247372
  return await run();
247372
247373
  } catch (error) {
247373
- if (error !== null && typeof error === "object" && !(STEP in error)) {
247374
+ if (error !== null && typeof error === "object" && !(STEP in error) && Object.isExtensible(error)) {
247374
247375
  Object.defineProperty(error, STEP, { value: step, enumerable: false });
247375
247376
  }
247376
247377
  throw error;
@@ -249761,7 +249762,53 @@ async function maybeAskToBuild(isNonInteractive, buildCommand) {
249761
249762
  }
249762
249763
  // src/core/version/artifacts.ts
249763
249764
  import { createHash as createHash2 } from "node:crypto";
249764
- import { join as join27, resolve as resolve10 } from "node:path";
249765
+ import { join as join28, resolve as resolve11 } from "node:path";
249766
+
249767
+ // src/core/version/project.ts
249768
+ import { dirname as dirname21, join as join27, resolve as resolve10 } from "node:path";
249769
+ var DEFAULT_BUILD_COMMAND = "npm run build";
249770
+ var DEFAULT_OUTPUT_DIRECTORY = "dist";
249771
+ async function resolvePublishTarget(projectRoot, overrides = {}) {
249772
+ const project = await readSettingsIfPresent(projectRoot);
249773
+ const root = project?.root ?? projectRoot ?? process.cwd();
249774
+ return {
249775
+ root,
249776
+ configDir: project ? dirname21(project.configPath) : join27(root, PROJECT_SUBDIR),
249777
+ buildCommand: project ? project.site?.buildCommand : DEFAULT_BUILD_COMMAND,
249778
+ outputDir: outputDirectory(project, root, overrides.outputDir),
249779
+ entitiesDir: project?.entitiesDir ?? "entities",
249780
+ agentsDir: project?.agentsDir ?? "agents"
249781
+ };
249782
+ }
249783
+ function outputDirectory(project, root, override) {
249784
+ const configured = override ?? (project ? project.site?.outputDirectory : DEFAULT_OUTPUT_DIRECTORY);
249785
+ return configured ? resolve10(root, configured) : null;
249786
+ }
249787
+ function requireOutputDir(target) {
249788
+ if (target.outputDir === null) {
249789
+ throw new ConfigNotFoundError("No site configuration found.", {
249790
+ hints: [
249791
+ {
249792
+ message: `Add 'site.outputDirectory' to your config.jsonc (e.g., "site": { "outputDirectory": "dist" })`
249793
+ },
249794
+ { message: `Or pass --output-dir <dir>, relative to ${target.root}` }
249795
+ ]
249796
+ });
249797
+ }
249798
+ return target.outputDir;
249799
+ }
249800
+ async function readSettingsIfPresent(projectRoot) {
249801
+ try {
249802
+ return await readProjectSettings(projectRoot);
249803
+ } catch (error) {
249804
+ if (error instanceof ConfigNotFoundError) {
249805
+ return null;
249806
+ }
249807
+ throw error;
249808
+ }
249809
+ }
249810
+
249811
+ // src/core/version/artifacts.ts
249765
249812
  var MAX_FILE_COUNT = 50000;
249766
249813
  var HASH_CONCURRENCY = 32;
249767
249814
  var ENTRY2 = "index.html";
@@ -249792,7 +249839,7 @@ async function collectSiteWorker(projectRoot) {
249792
249839
  return null;
249793
249840
  }
249794
249841
  const { config, modules, assetsDir } = built;
249795
- const entry = resolve10(config.configDir, config.main);
249842
+ const entry = resolve11(config.configDir, config.main);
249796
249843
  const main = modules.find((m) => m.absolutePath === entry)?.name;
249797
249844
  if (!main) {
249798
249845
  throw new InvalidInputError(`The Worker's entry module ${config.main} is not among the ${modules.length} modules collected from ${config.configDir}.`);
@@ -249822,66 +249869,31 @@ async function readRawResources(dir) {
249822
249869
  const payloads = {};
249823
249870
  for (const relativePath of files.sort()) {
249824
249871
  const name = relativePath.replace(/\.jsonc?$/, "");
249825
- payloads[name] = await readJsonFile(join27(dir, ...relativePath.split("/")));
249872
+ payloads[name] = await readJsonFile(join28(dir, ...relativePath.split("/")));
249826
249873
  }
249827
249874
  return payloads;
249828
249875
  }
249829
249876
  async function collectResources(configDir, dirs) {
249830
249877
  const [entities, agents] = await Promise.all([
249831
- readRawResources(join27(configDir, dirs.entitiesDir)),
249832
- readRawResources(join27(configDir, dirs.agentsDir))
249878
+ readRawResources(join28(configDir, dirs.entitiesDir)),
249879
+ readRawResources(join28(configDir, dirs.agentsDir))
249833
249880
  ]);
249834
249881
  return { entities, agents };
249835
249882
  }
249883
+ async function collectArtifacts(target) {
249884
+ const siteWorker = await collectSiteWorker(target.root);
249885
+ return {
249886
+ files: siteWorker ? [] : await collectBuildOutput(requireOutputDir(target)),
249887
+ ...siteWorker ? { siteWorker } : {},
249888
+ ...await collectResources(target.configDir, target)
249889
+ };
249890
+ }
249836
249891
  // src/core/version/gate.ts
249837
249892
  var VERSIONS_API_ENV = "BASE44_VERSIONS_API";
249838
249893
  function versionsApiEnabled(env = process.env) {
249839
249894
  const value = env[VERSIONS_API_ENV];
249840
249895
  return value === "1" || value === "true";
249841
249896
  }
249842
- // src/core/version/project.ts
249843
- import { dirname as dirname21, join as join28, resolve as resolve11 } from "node:path";
249844
- var DEFAULT_BUILD_COMMAND = "npm run build";
249845
- var DEFAULT_OUTPUT_DIRECTORY = "dist";
249846
- async function resolvePublishTarget(projectRoot, overrides = {}) {
249847
- const project = await readSettingsIfPresent(projectRoot);
249848
- const root = project?.root ?? projectRoot ?? process.cwd();
249849
- return {
249850
- root,
249851
- configDir: project ? dirname21(project.configPath) : join28(root, PROJECT_SUBDIR),
249852
- buildCommand: project ? project.site?.buildCommand : DEFAULT_BUILD_COMMAND,
249853
- outputDir: outputDirectory(project, root, overrides.outputDir),
249854
- entitiesDir: project?.entitiesDir ?? "entities",
249855
- agentsDir: project?.agentsDir ?? "agents"
249856
- };
249857
- }
249858
- function outputDirectory(project, root, override) {
249859
- const configured = override ?? (project ? project.site?.outputDirectory : DEFAULT_OUTPUT_DIRECTORY);
249860
- return configured ? resolve11(root, configured) : null;
249861
- }
249862
- function requireOutputDir(target) {
249863
- if (target.outputDir === null) {
249864
- throw new ConfigNotFoundError("No site configuration found.", {
249865
- hints: [
249866
- {
249867
- message: `Add 'site.outputDirectory' to your config.jsonc (e.g., "site": { "outputDirectory": "dist" })`
249868
- },
249869
- { message: `Or pass --output-dir <dir>, relative to ${target.root}` }
249870
- ]
249871
- });
249872
- }
249873
- return target.outputDir;
249874
- }
249875
- async function readSettingsIfPresent(projectRoot) {
249876
- try {
249877
- return await readProjectSettings(projectRoot);
249878
- } catch (error) {
249879
- if (error instanceof ConfigNotFoundError) {
249880
- return null;
249881
- }
249882
- throw error;
249883
- }
249884
- }
249885
249897
  // src/cli/commands/project/build.ts
249886
249898
  async function buildAction(ctx) {
249887
249899
  const app = requireApp(ctx);
@@ -250854,9 +250866,7 @@ function concurrencyOption() {
250854
250866
  async function publishAction(ctx, options) {
250855
250867
  const { runTask, log, jsonMode } = ctx;
250856
250868
  const app = requireApp(ctx);
250857
- const target = await resolvePublishTarget(app.projectRoot, {
250858
- outputDir: options.outputDir
250859
- });
250869
+ const target = await tagStep("create_version", () => resolvePublishTarget(app.projectRoot, { outputDir: options.outputDir }));
250860
250870
  if (options.build !== false) {
250861
250871
  await tagStep("build", () => runSiteBuild(ctx, {
250862
250872
  root: target.root,
@@ -250866,20 +250876,13 @@ async function publishAction(ctx, options) {
250866
250876
  }
250867
250877
  const gitHash = await resolveProvenanceCommit(target.root, options.gitHash);
250868
250878
  const result = await runTask("Publishing...", async (updateMessage) => {
250869
- const artifacts = await tagStep("create_version", async () => {
250870
- const siteWorker = await collectSiteWorker(target.root);
250871
- return {
250872
- files: siteWorker ? [] : await collectBuildOutput(requireOutputDir(target)),
250873
- ...siteWorker ? { siteWorker } : {},
250874
- ...await collectResources(target.configDir, target)
250875
- };
250876
- });
250879
+ const artifacts = await tagStep("create_version", () => collectArtifacts(target));
250877
250880
  return await publishVersion(artifacts, {
250878
250881
  sourceCommit: gitHash,
250879
250882
  target: options.target,
250880
250883
  concurrency: options.concurrency,
250881
250884
  progress: {
250882
- onDeclared: ({ fileCount, owedFiles }) => updateMessage(`Uploading ${owedFiles} of ${fileCount} files`),
250885
+ onDeclared: ({ fileCount }) => updateMessage(`Uploading ${fileCount} files`),
250883
250886
  onUpload: ({ uploadedFiles, totalFiles }) => updateMessage(`Uploaded ${uploadedFiles} of ${totalFiles} files`)
250884
250887
  }
250885
250888
  });
@@ -251589,19 +251592,17 @@ function getTypesCommand() {
251589
251592
  }
251590
251593
 
251591
251594
  // src/cli/commands/versions/create.ts
251592
- async function createAction2({ runTask, jsonMode, app }, options) {
251593
- const target = await resolvePublishTarget(app?.projectRoot, {
251595
+ async function createAction2(ctx, options) {
251596
+ const { runTask, jsonMode } = ctx;
251597
+ const target = await resolvePublishTarget(requireApp(ctx).projectRoot, {
251594
251598
  outputDir: options.outputDir
251595
251599
  });
251596
251600
  const gitHash = await resolveProvenanceCommit(target.root, options.gitHash);
251597
- const version = await runTask("Creating version...", async (updateMessage) => await createVersion({
251598
- files: await collectBuildOutput(requireOutputDir(target)),
251599
- ...await collectResources(target.configDir, target)
251600
- }, {
251601
+ const version = await runTask("Creating version...", async (updateMessage) => await createVersion(await collectArtifacts(target), {
251601
251602
  sourceCommit: gitHash,
251602
251603
  concurrency: options.concurrency,
251603
251604
  progress: {
251604
- onDeclared: ({ fileCount, owedFiles }) => updateMessage(`Uploading ${owedFiles} of ${fileCount} files`),
251605
+ onDeclared: ({ fileCount }) => updateMessage(`Uploading ${fileCount} files`),
251605
251606
  onUpload: ({ uploadedFiles, totalFiles }) => updateMessage(`Uploaded ${uploadedFiles} of ${totalFiles} files`)
251606
251607
  }
251607
251608
  }), {
@@ -251635,7 +251636,7 @@ async function deployAction3({ runTask, jsonMode }, versionId, options) {
251635
251636
  };
251636
251637
  }
251637
251638
  function getVersionDeployCommand() {
251638
- return new Base44Command("deploy").description("Point an environment at an already-recorded version (also the rollback)").argument("<version-id>", "The version to serve").option("--target <name>", "Environment to point at it").action(deployAction3);
251639
+ return new Base44Command("deploy").description("Point an environment at an already-recorded version (also the rollback)").argument("<version-id>", "The version to serve").addOption(targetOption()).action(deployAction3);
251639
251640
  }
251640
251641
 
251641
251642
  // src/cli/commands/versions/index.ts
@@ -260359,4 +260360,4 @@ export {
260359
260360
  runCLI
260360
260361
  };
260361
260362
 
260362
- //# debugId=A3CC3878ECA39CF664756E2164756E21
260363
+ //# debugId=7059640A5E6CFF9564756E2164756E21