@fluid-app/fluid-cli-portal 0.1.42 → 0.1.44

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/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { C as writeMappings, S as updateMapping, _ as deriveSlug, a as buildThemeIdToSlugMap, b as resolveIdToSlug, c as transformNavigationItems, d as transformTheme, f as buildSnapshot, g as writeSnapshot, h as readSnapshot, i as buildNavigationIdToSlugMap, l as transformProfile, m as diffAgainstSnapshot, o as deriveScreenSlug, p as computeFileHash, r as buildIdToSlugMap, s as transformNavigation, t as pullCommand, u as transformScreen, v as readMappings, x as resolveSlugToId, y as removeMapping } from "./pull-Cl7omGLf.mjs";
1
+ import { A as fluid_os_v0_create_fluid_osversion, B as fluid_os_v0_update_fluid_osnavigation, C as writeMappings, D as fluid_os_v0_create_fluid_osprofile, E as fluid_os_v0_create_fluid_osnavigation_item, F as fluid_os_v0_delete_fluid_osscreen, G as fluid_os_v0_update_fluid_osversion, H as fluid_os_v0_update_fluid_osprofile, I as fluid_os_v0_delete_fluid_ostheme, K as createFetchClient, L as fluid_os_v0_list_fluid_osdefinitions, M as fluid_os_v0_delete_fluid_osnavigation, N as fluid_os_v0_delete_fluid_osnavigation_item, O as fluid_os_v0_create_fluid_osscreen, P as fluid_os_v0_delete_fluid_osprofile, R as fluid_os_v0_list_fluid_osnavigation_items, S as updateMapping, T as fluid_os_v0_create_fluid_osnavigation, U as fluid_os_v0_update_fluid_osscreen, V as fluid_os_v0_update_fluid_osnavigation_item, W as fluid_os_v0_update_fluid_ostheme, _ as deriveSlug, a as buildThemeIdToSlugMap, b as resolveIdToSlug, c as transformNavigationItems, d as transformTheme, f as buildSnapshot, g as writeSnapshot, h as readSnapshot, i as buildNavigationIdToSlugMap, j as fluid_os_v0_create_widget_package_version, k as fluid_os_v0_create_fluid_ostheme, l as transformProfile, m as diffAgainstSnapshot, o as deriveScreenSlug, p as computeFileHash, r as buildIdToSlugMap, s as transformNavigation, t as pullCommand, u as transformScreen, v as readMappings, w as fluid_os_v0_complete_widget_package_version_upload, x as resolveSlugToId, y as removeMapping, z as fluid_os_v0_list_fluid_osversions } from "./pull-CG5dELOX.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { Command } from "commander";
4
4
  import chalk from "chalk";
@@ -12,7 +12,6 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileS
12
12
  import Handlebars from "handlebars";
13
13
  import { execa } from "execa";
14
14
  import os from "node:os";
15
- import { createFetchClient, fluidOs } from "@fluid-app/fluidos-api-client";
16
15
  import { createHash } from "node:crypto";
17
16
  import fs from "fs-extra";
18
17
  import { isJsonValue } from "@fluid-app/portal-core/remote-dom-widget-package";
@@ -700,11 +699,14 @@ async function gitRemoteBranchExists(cwd, remoteUrl, branch = "main") {
700
699
  /**
701
700
  * Adopt `FETCH_HEAD` as the current (unborn) branch's base: point the
702
701
  * branch ref at it and load its tree into the index, leaving the working
703
- * tree untouched. The next auto-commit then records the local project
704
- * tree as a child of the remote history — local files win, remote-only
705
- * files are recorded as deletions — so the push fast-forwards instead of
706
- * being rejected for unrelated history. Only call when `hasCommits` is
707
- * false; with local commits it would silently rewrite the branch ref.
702
+ * tree untouched. The next auto-commit (run with `ignoreRemovals`) then
703
+ * records the local project tree on top of the remote history — local
704
+ * additions/edits win, and remote-only files survive because a
705
+ * content-only local dir (e.g. populated by `fluid portal pull`) is no
706
+ * statement about what the full repo tracks — so the push fast-forwards
707
+ * instead of being rejected for unrelated history. Only call when
708
+ * `hasCommits` is false; with local commits it would silently rewrite
709
+ * the branch ref.
708
710
  * Mirrors the widget CLI's first-push adoption (the backend provisions
709
711
  * repos with an auto-init/template commit, so a fresh root commit is
710
712
  * always unrelated history).
@@ -781,7 +783,9 @@ async function gitMergeFastForward(cwd) {
781
783
  }
782
784
  }
783
785
  /**
784
- * `git add -A && git commit -m <message>`.
786
+ * `git add -A && git commit -m <message>` (or, with
787
+ * `{ ignoreRemovals: true }`, `git add --ignore-removal .` — see
788
+ * GitAutoCommitOptions).
785
789
  *
786
790
  * `git add -A` intentionally stages the whole work tree: a portal's
787
791
  * provisioned repo tracks the entire project (it's seeded from the
@@ -795,9 +799,14 @@ async function gitMergeFastForward(cwd) {
795
799
  * identity so the commit isn't rejected. "nothing to commit" is treated
796
800
  * as a no-op, not an error.
797
801
  */
798
- async function gitAutoCommit(cwd, message) {
802
+ async function gitAutoCommit(cwd, message, options = {}) {
803
+ const addArgs = options.ignoreRemovals ? [
804
+ "add",
805
+ "--ignore-removal",
806
+ "."
807
+ ] : ["add", "-A"];
799
808
  try {
800
- await execa("git", ["add", "-A"], { cwd });
809
+ await execa("git", addArgs, { cwd });
801
810
  } catch (err) {
802
811
  throw toGitError(err, "add");
803
812
  }
@@ -820,7 +829,7 @@ async function gitAutoCommit(cwd, message) {
820
829
  cwd,
821
830
  stdio: [
822
831
  "ignore",
823
- "inherit",
832
+ "pipe",
824
833
  "pipe"
825
834
  ]
826
835
  });
@@ -829,7 +838,7 @@ async function gitAutoCommit(cwd, message) {
829
838
  if (missing) throw missing;
830
839
  const e = err;
831
840
  const streams = `${typeof e.stdout === "string" ? e.stdout : ""}\n${typeof e.stderr === "string" ? e.stderr : ""}`;
832
- if (/nothing to commit/i.test(streams)) return;
841
+ if (/nothing to commit|no changes added to commit/i.test(streams)) return;
833
842
  throw toGitError(err, "commit");
834
843
  }
835
844
  }
@@ -1150,7 +1159,7 @@ async function autoPull(cwd) {
1150
1159
  console.log(chalk.yellow("No portal/ directory found.") + " Attempting to pull content...");
1151
1160
  console.log();
1152
1161
  try {
1153
- const { pullCommand } = await import("./pull-Cl7omGLf.mjs").then((n) => n.n);
1162
+ const { pullCommand } = await import("./pull-CG5dELOX.mjs").then((n) => n.n);
1154
1163
  await pullCommand.parseAsync([], { from: "user" });
1155
1164
  return hasPortalContent(cwd);
1156
1165
  } catch (err) {
@@ -1508,7 +1517,7 @@ async function runPortalGitSync(options) {
1508
1517
  await gitFetch(cwd, remoteUrl, branch);
1509
1518
  await gitAdoptFetchHead(cwd);
1510
1519
  }
1511
- if (await hasUncommittedChanges(cwd)) await gitAutoCommit(cwd, commitMessage);
1520
+ if (await hasUncommittedChanges(cwd)) await gitAutoCommit(cwd, commitMessage, { ignoreRemovals: true });
1512
1521
  return await pushCommitted(cwd, remoteUrl, branch);
1513
1522
  }
1514
1523
  await gitFetch(cwd, remoteUrl, branch);
@@ -1653,7 +1662,7 @@ async function pushScreens(client, defId, portalDir, changes, mappings) {
1653
1662
  const slug = slugFromPath(file);
1654
1663
  try {
1655
1664
  const local = await readPortalFile(portalDir, file);
1656
- const newId = (await fluidOs.fluid_os_v0_create_fluid_osscreen(client, defId, { screen: {
1665
+ const newId = (await fluid_os_v0_create_fluid_osscreen(client, defId, { screen: {
1657
1666
  name: local.name,
1658
1667
  slug,
1659
1668
  component_tree: toApiComponentTree(local.component_tree)
@@ -1694,7 +1703,7 @@ async function pushScreens(client, defId, portalDir, changes, mappings) {
1694
1703
  }
1695
1704
  try {
1696
1705
  const local = await readPortalFile(portalDir, file);
1697
- await fluidOs.fluid_os_v0_update_fluid_osscreen(client, defId, screenId, { screen: {
1706
+ await fluid_os_v0_update_fluid_osscreen(client, defId, screenId, { screen: {
1698
1707
  name: local.name,
1699
1708
  slug,
1700
1709
  component_tree: toApiComponentTree(local.component_tree)
@@ -1733,7 +1742,7 @@ async function pushScreens(client, defId, portalDir, changes, mappings) {
1733
1742
  };
1734
1743
  }
1735
1744
  try {
1736
- await fluidOs.fluid_os_v0_delete_fluid_osscreen(client, defId, screenId);
1745
+ await fluid_os_v0_delete_fluid_osscreen(client, defId, screenId);
1737
1746
  currentMappings = removeMapping(currentMappings, "screens", slug);
1738
1747
  results.push({
1739
1748
  file,
@@ -1768,7 +1777,7 @@ async function pushThemes(client, defId, portalDir, changes, mappings) {
1768
1777
  const slug = slugFromPath(file);
1769
1778
  try {
1770
1779
  const local = await readPortalFile(portalDir, file);
1771
- const newId = (await fluidOs.fluid_os_v0_create_fluid_ostheme(client, defId, { theme: {
1780
+ const newId = (await fluid_os_v0_create_fluid_ostheme(client, defId, { theme: {
1772
1781
  name: local.name,
1773
1782
  active: local.active,
1774
1783
  config: local.config
@@ -1809,7 +1818,7 @@ async function pushThemes(client, defId, portalDir, changes, mappings) {
1809
1818
  }
1810
1819
  try {
1811
1820
  const local = await readPortalFile(portalDir, file);
1812
- await fluidOs.fluid_os_v0_update_fluid_ostheme(client, defId, themeId, { theme: {
1821
+ await fluid_os_v0_update_fluid_ostheme(client, defId, themeId, { theme: {
1813
1822
  name: local.name,
1814
1823
  active: local.active,
1815
1824
  config: local.config
@@ -1848,7 +1857,7 @@ async function pushThemes(client, defId, portalDir, changes, mappings) {
1848
1857
  };
1849
1858
  }
1850
1859
  try {
1851
- await fluidOs.fluid_os_v0_delete_fluid_ostheme(client, defId, themeId);
1860
+ await fluid_os_v0_delete_fluid_ostheme(client, defId, themeId);
1852
1861
  currentMappings = removeMapping(currentMappings, "themes", slug);
1853
1862
  results.push({
1854
1863
  file,
@@ -1918,7 +1927,7 @@ async function pushNavigations(client, defId, portalDir, changes, mappings) {
1918
1927
  const slug = slugFromPath(file);
1919
1928
  try {
1920
1929
  const local = await readPortalFile(portalDir, file);
1921
- const newId = (await fluidOs.fluid_os_v0_create_fluid_osnavigation(client, defId, { navigation: {
1930
+ const newId = (await fluid_os_v0_create_fluid_osnavigation(client, defId, { navigation: {
1922
1931
  name: local.name,
1923
1932
  platform: local.platform
1924
1933
  } })).navigation?.id;
@@ -1928,7 +1937,7 @@ async function pushNavigations(client, defId, portalDir, changes, mappings) {
1928
1937
  const localToServerId = /* @__PURE__ */ new Map();
1929
1938
  for (const item of resolvedItems) {
1930
1939
  const resolvedParentId = item.parent_id != null ? localToServerId.get(item.parent_id) ?? item.parent_id : void 0;
1931
- const created = await fluidOs.fluid_os_v0_create_fluid_osnavigation_item(client, defId, newId, { navigation_item: {
1940
+ const created = await fluid_os_v0_create_fluid_osnavigation_item(client, defId, newId, { navigation_item: {
1932
1941
  label: item.label ?? "",
1933
1942
  position: item.position ?? 0,
1934
1943
  icon: item.icon ?? void 0,
@@ -1975,15 +1984,15 @@ async function pushNavigations(client, defId, portalDir, changes, mappings) {
1975
1984
  }
1976
1985
  try {
1977
1986
  const local = await readPortalFile(portalDir, file);
1978
- await fluidOs.fluid_os_v0_update_fluid_osnavigation(client, defId, navId, { navigation: {
1987
+ await fluid_os_v0_update_fluid_osnavigation(client, defId, navId, { navigation: {
1979
1988
  name: local.name,
1980
1989
  platform: local.platform
1981
1990
  } });
1982
1991
  const resolvedItems = flattenNavigationItems(resolveNavigationItemScreenIds(local.navigation_items, currentMappings));
1983
- const serverItems = (await fluidOs.fluid_os_v0_list_fluid_osnavigation_items(client, defId, navId)).navigation_items ?? [];
1992
+ const serverItems = (await fluid_os_v0_list_fluid_osnavigation_items(client, defId, navId)).navigation_items ?? [];
1984
1993
  const serverById = new Map(serverItems.map((s) => [s.id, s]));
1985
1994
  const localIds = new Set(resolvedItems.filter((i) => i.id).map((i) => i.id));
1986
- for (const serverItem of serverItems) if (!localIds.has(serverItem.id)) await fluidOs.fluid_os_v0_delete_fluid_osnavigation_item(client, defId, navId, serverItem.id);
1995
+ for (const serverItem of serverItems) if (!localIds.has(serverItem.id)) await fluid_os_v0_delete_fluid_osnavigation_item(client, defId, navId, serverItem.id);
1987
1996
  const localToServerId = /* @__PURE__ */ new Map();
1988
1997
  for (const item of resolvedItems) {
1989
1998
  const resolvedParentId = item.parent_id != null ? localToServerId.get(item.parent_id) ?? item.parent_id : void 0;
@@ -1996,9 +2005,9 @@ async function pushNavigations(client, defId, portalDir, changes, mappings) {
1996
2005
  source: item.source ?? void 0,
1997
2006
  parent_id: resolvedParentId
1998
2007
  };
1999
- if (item.id && serverById.has(item.id)) await fluidOs.fluid_os_v0_update_fluid_osnavigation_item(client, defId, navId, item.id, { navigation_item: body });
2008
+ if (item.id && serverById.has(item.id)) await fluid_os_v0_update_fluid_osnavigation_item(client, defId, navId, item.id, { navigation_item: body });
2000
2009
  else {
2001
- const created = await fluidOs.fluid_os_v0_create_fluid_osnavigation_item(client, defId, navId, { navigation_item: {
2010
+ const created = await fluid_os_v0_create_fluid_osnavigation_item(client, defId, navId, { navigation_item: {
2002
2011
  ...body,
2003
2012
  label: body.label ?? "",
2004
2013
  position: body.position ?? 0
@@ -2040,7 +2049,7 @@ async function pushNavigations(client, defId, portalDir, changes, mappings) {
2040
2049
  };
2041
2050
  }
2042
2051
  try {
2043
- await fluidOs.fluid_os_v0_delete_fluid_osnavigation(client, defId, navId);
2052
+ await fluid_os_v0_delete_fluid_osnavigation(client, defId, navId);
2044
2053
  currentMappings = removeMapping(currentMappings, "navigations", slug);
2045
2054
  results.push({
2046
2055
  file,
@@ -2074,8 +2083,7 @@ async function pushProfiles(client, defId, portalDir, changes, mappings) {
2074
2083
  for (const file of changes.new) {
2075
2084
  const slug = slugFromPath(file);
2076
2085
  try {
2077
- const body = resolveProfileBody(await readPortalFile(portalDir, file), currentMappings);
2078
- const newId = (await fluidOs.fluid_os_v0_create_fluid_osprofile(client, defId, { profile: body })).profile?.id;
2086
+ const newId = (await fluid_os_v0_create_fluid_osprofile(client, defId, { profile: resolveProfileBody(await readPortalFile(portalDir, file), currentMappings) })).profile?.id;
2079
2087
  if (newId != null) currentMappings = updateMapping(currentMappings, "profiles", slug, newId);
2080
2088
  results.push({
2081
2089
  file,
@@ -2111,8 +2119,7 @@ async function pushProfiles(client, defId, portalDir, changes, mappings) {
2111
2119
  };
2112
2120
  }
2113
2121
  try {
2114
- const body = resolveProfileBody(await readPortalFile(portalDir, file), currentMappings);
2115
- await fluidOs.fluid_os_v0_update_fluid_osprofile(client, defId, profileId, { profile: body });
2122
+ await fluid_os_v0_update_fluid_osprofile(client, defId, profileId, { profile: resolveProfileBody(await readPortalFile(portalDir, file), currentMappings) });
2116
2123
  results.push({
2117
2124
  file,
2118
2125
  action: "updated",
@@ -2147,7 +2154,7 @@ async function pushProfiles(client, defId, portalDir, changes, mappings) {
2147
2154
  };
2148
2155
  }
2149
2156
  try {
2150
- await fluidOs.fluid_os_v0_delete_fluid_osprofile(client, defId, profileId);
2157
+ await fluid_os_v0_delete_fluid_osprofile(client, defId, profileId);
2151
2158
  currentMappings = removeMapping(currentMappings, "profiles", slug);
2152
2159
  results.push({
2153
2160
  file,
@@ -2404,7 +2411,7 @@ async function selectDefinition(client, appName) {
2404
2411
  const definitions = [];
2405
2412
  let page = 1;
2406
2413
  while (true) {
2407
- const response = await fluidOs.fluid_os_v0_list_fluid_osdefinitions(client, {
2414
+ const response = await fluid_os_v0_list_fluid_osdefinitions(client, {
2408
2415
  page,
2409
2416
  per_page: 500
2410
2417
  });
@@ -3871,7 +3878,7 @@ function getWidgetPackageCompleteUploadRoute(owner, version) {
3871
3878
  async function requestWidgetPackageUploadSession(client, owner, request) {
3872
3879
  const payload = buildWidgetPackageUploadSessionPayload(request);
3873
3880
  try {
3874
- return normalizeWidgetPackageUploadSession(owner.kind === "company" ? await fluidOs.fluid_os_v0_create_widget_package_version(client, payload) : await client.post(getWidgetPackageUploadSessionRoute(owner), payload), request.version, request.artifacts);
3881
+ return normalizeWidgetPackageUploadSession(owner.kind === "company" ? await fluid_os_v0_create_widget_package_version(client, payload) : await client.post(getWidgetPackageUploadSessionRoute(owner), payload), request.version, request.artifacts);
3875
3882
  } catch (err) {
3876
3883
  if (err instanceof WidgetPackageUploadError) throw err;
3877
3884
  throw new WidgetPackageUploadError("SESSION_REQUEST_FAILED", `Failed to create widget package upload session: ${formatUnknownError(err)}`);
@@ -3910,7 +3917,7 @@ async function uploadWidgetPackageArtifacts(session, artifacts, fetchImpl = fetc
3910
3917
  async function completeWidgetPackageUpload(client, owner, version, packageKey, artifacts) {
3911
3918
  const payload = buildWidgetPackageCompleteUploadPayload(packageKey, artifacts);
3912
3919
  try {
3913
- return normalizeWidgetPackageCompleteResponse(owner.kind === "company" ? await fluidOs.fluid_os_v0_complete_widget_package_version_upload(client, version, payload) : await client.post(getWidgetPackageCompleteUploadRoute(owner, version), payload), version);
3920
+ return normalizeWidgetPackageCompleteResponse(owner.kind === "company" ? await fluid_os_v0_complete_widget_package_version_upload(client, version, payload) : await client.post(getWidgetPackageCompleteUploadRoute(owner, version), payload), version);
3914
3921
  } catch (err) {
3915
3922
  if (err instanceof WidgetPackageUploadError) throw err;
3916
3923
  throw new WidgetPackageUploadError("COMPLETE_UPLOAD_FAILED", `Failed to complete widget package upload: ${formatUnknownError(err)}`);
@@ -4527,7 +4534,7 @@ const createVersionCommand = new Command("create").description("Create a new ver
4527
4534
  console.log(chalk.bold("Creating version..."));
4528
4535
  let result;
4529
4536
  try {
4530
- result = await fluidOs.fluid_os_v0_create_fluid_osversion(client, definitionId);
4537
+ result = await fluid_os_v0_create_fluid_osversion(client, definitionId);
4531
4538
  } catch (err) {
4532
4539
  console.error(chalk.red("Error:") + " Failed to create version — " + (err instanceof Error ? err.message : String(err)));
4533
4540
  process.exit(1);
@@ -4545,7 +4552,7 @@ const createVersionCommand = new Command("create").description("Create a new ver
4545
4552
  if (options.activate) {
4546
4553
  console.log("Activating version...");
4547
4554
  try {
4548
- await fluidOs.fluid_os_v0_update_fluid_osversion(client, definitionId, version.id, { version: { active: true } });
4555
+ await fluid_os_v0_update_fluid_osversion(client, definitionId, version.id, { version: { active: true } });
4549
4556
  } catch (err) {
4550
4557
  console.error(chalk.red("Error:") + " Failed to activate version — " + (err instanceof Error ? err.message : String(err)));
4551
4558
  process.exit(1);
@@ -4560,7 +4567,7 @@ const listVersionCommand = new Command("list").description("List all versions of
4560
4567
  const definitionId = await requireDefinitionId();
4561
4568
  let result;
4562
4569
  try {
4563
- result = await fluidOs.fluid_os_v0_list_fluid_osversions(client, definitionId);
4570
+ result = await fluid_os_v0_list_fluid_osversions(client, definitionId);
4564
4571
  } catch (err) {
4565
4572
  console.error(chalk.red("Error:") + " Failed to list versions — " + (err instanceof Error ? err.message : String(err)));
4566
4573
  process.exit(1);
@@ -4603,7 +4610,7 @@ const activateVersionCommand = new Command("activate").description("Activate a s
4603
4610
  console.log();
4604
4611
  console.log(chalk.bold("Activating version..."));
4605
4612
  try {
4606
- await fluidOs.fluid_os_v0_update_fluid_osversion(client, definitionId, versionId, { version: { active: true } });
4613
+ await fluid_os_v0_update_fluid_osversion(client, definitionId, versionId, { version: { active: true } });
4607
4614
  } catch (err) {
4608
4615
  console.error(chalk.red("Error:") + " Failed to activate version — " + (err instanceof Error ? err.message : String(err)));
4609
4616
  process.exit(1);