@cmssy/cli 19.24.0 → 19.25.0

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.
Files changed (2) hide show
  1. package/dist/index.js +28 -7
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -114,6 +114,14 @@ var SAVE_BLOCK_MANIFEST_MUTATION = `mutation CliSaveBlockManifest($blocks: JSON!
114
114
  }
115
115
  }
116
116
  }`;
117
+ var SAVE_BLOCK_MANIFEST_ALLOWING_REMOVALS_MUTATION = `mutation CliSaveBlockManifestAllowingRemovals($blocks: JSON!, $regions: JSON, $expectedHash: String, $onlyIfAbsent: Boolean, $allowLossy: Boolean) {
118
+ blockManifest {
119
+ save(blocks: $blocks, regions: $regions, expectedHash: $expectedHash, onlyIfAbsent: $onlyIfAbsent, allowLossy: $allowLossy, allowRemovals: true) {
120
+ hash
121
+ updatedAt
122
+ }
123
+ }
124
+ }`;
117
125
  async function fetchMyWorkspaces(options) {
118
126
  const data = await adminGraphql(WORKSPACES_MINE_QUERY, {}, options);
119
127
  return data.workspace.mine;
@@ -152,9 +160,10 @@ async function fetchBlockManifestHash(options) {
152
160
  return data.blockManifest.get?.hash ?? null;
153
161
  }
154
162
  async function saveBlockManifest(manifest, options, guard = {}) {
163
+ const { allowRemovals, ...variables } = guard;
155
164
  const data = await adminGraphql(
156
- SAVE_BLOCK_MANIFEST_MUTATION,
157
- { ...manifest, ...guard },
165
+ allowRemovals ? SAVE_BLOCK_MANIFEST_ALLOWING_REMOVALS_MUTATION : SAVE_BLOCK_MANIFEST_MUTATION,
166
+ { ...manifest, ...variables },
158
167
  {
159
168
  ...options,
160
169
  denied: NEEDS_MANIFEST_WRITE_HINT
@@ -1596,7 +1605,7 @@ var CONFIG_CANDIDATES = [
1596
1605
  var SYNC_MANIFEST_USAGE = [
1597
1606
  " cmssy sync-manifest [--blocks <path>] [--config <path>] [--token <cs_...>]",
1598
1607
  " [--org <slug>] [--workspace <slug>] [--dry-run]",
1599
- " [--allow-lossy] [--help]"
1608
+ " [--allow-lossy] [--allow-removals] [--help]"
1600
1609
  ];
1601
1610
  function hasBlocksModule(cwd) {
1602
1611
  return BLOCKS_CANDIDATES.some(
@@ -1715,6 +1724,9 @@ function describe(manifest) {
1715
1724
  function plural(count, noun) {
1716
1725
  return `${count} ${noun}${count === 1 ? "" : "s"}`;
1717
1726
  }
1727
+ function removesFromWorkspace(impact) {
1728
+ return impact.removedTypes.length > 0 || impact.removedFields.length > 0 || impact.removedRegions.length > 0;
1729
+ }
1718
1730
  function describeImpact(impact) {
1719
1731
  const lines = [];
1720
1732
  for (const removed of impact.removedTypes) {
@@ -1867,12 +1879,19 @@ async function runSyncManifest(options, deps) {
1867
1879
  );
1868
1880
  for (const line of effects) deps.log(line);
1869
1881
  for (const line of describe(manifest)) deps.log(line);
1870
- if (impact.lossyMoves > 0 && !options.allowLossy) {
1882
+ const refusedLossy = impact.lossyMoves > 0 && !options.allowLossy;
1883
+ const refusedRemovals = removesFromWorkspace(impact) && !options.allowRemovals;
1884
+ if (refusedLossy) {
1871
1885
  deps.log(
1872
1886
  `cmssy: not pushed - rerun with --allow-lossy to accept dropping those values`
1873
1887
  );
1874
- return 1;
1875
1888
  }
1889
+ if (refusedRemovals) {
1890
+ deps.log(
1891
+ `cmssy: not pushed - it removes the block types, fields or regions listed above from ${org}/${slug}; rerun with --allow-removals if that is intended`
1892
+ );
1893
+ }
1894
+ if (refusedLossy || refusedRemovals) return 1;
1876
1895
  if (options.dryRun) {
1877
1896
  deps.log("cmssy: dry run - nothing pushed");
1878
1897
  return 0;
@@ -1881,7 +1900,8 @@ async function runSyncManifest(options, deps) {
1881
1900
  try {
1882
1901
  saved = await saveBlockManifest(manifest, scoped, {
1883
1902
  ...impact.activeHash === null ? { onlyIfAbsent: true } : { expectedHash: impact.activeHash },
1884
- ...options.allowLossy ? { allowLossy: true } : {}
1903
+ ...options.allowLossy ? { allowLossy: true } : {},
1904
+ ...options.allowRemovals ? { allowRemovals: true } : {}
1885
1905
  });
1886
1906
  } catch (error) {
1887
1907
  if (error instanceof CliError && error.code === "CONFLICT") {
@@ -2884,7 +2904,8 @@ async function main() {
2884
2904
  org: flagValue(args, "--org"),
2885
2905
  workspace: flagValue(args, "--workspace"),
2886
2906
  dryRun: hasFlag(args, "--dry-run"),
2887
- allowLossy: hasFlag(args, "--allow-lossy")
2907
+ allowLossy: hasFlag(args, "--allow-lossy"),
2908
+ allowRemovals: hasFlag(args, "--allow-removals")
2888
2909
  },
2889
2910
  {
2890
2911
  cwd: process.cwd(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/cli",
3
- "version": "19.24.0",
3
+ "version": "19.25.0",
4
4
  "description": "The cmssy CLI: `cmssy init` wires cmssy into an existing Next.js, Astro or React Router app; `cmssy link` connects it to a workspace and verifies the editor wiring.",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "esbuild": "^0.27.7",
31
- "@cmssy/core": "19.24.0"
31
+ "@cmssy/core": "19.25.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^20.0.0",