kenso 0.1.177 → 0.1.178

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/kenso.js CHANGED
@@ -3530,7 +3530,7 @@ var VERSION;
3530
3530
  var init_version = __esm({
3531
3531
  "src/core/version.ts"() {
3532
3532
  "use strict";
3533
- VERSION = true ? "0.1.177" : "0.0.0-dev";
3533
+ VERSION = true ? "0.1.178" : "0.0.0-dev";
3534
3534
  }
3535
3535
  });
3536
3536
 
@@ -18788,6 +18788,17 @@ __export(pull_exports, {
18788
18788
  });
18789
18789
  import { mkdir, readFile as readFile11, writeFile as writeFile5 } from "node:fs/promises";
18790
18790
  import { dirname as dirname3, join as join20, resolve as resolve13 } from "node:path";
18791
+ function caseTwins(paths) {
18792
+ const kept = /* @__PURE__ */ new Map();
18793
+ const twins = /* @__PURE__ */ new Map();
18794
+ for (const path of [...paths].sort()) {
18795
+ const key = path.toLowerCase();
18796
+ const twin = kept.get(key);
18797
+ if (twin !== void 0) twins.set(path, twin);
18798
+ else kept.set(key, path);
18799
+ }
18800
+ return twins;
18801
+ }
18791
18802
  var command62, pull_default;
18792
18803
  var init_pull = __esm({
18793
18804
  "src/commands/studio/pull.ts"() {
@@ -18804,7 +18815,7 @@ var init_pull = __esm({
18804
18815
  action: "pull",
18805
18816
  summary: "Write a template version's files to a folder",
18806
18817
  effect: "read",
18807
- description: `Reads GET /v1/asset-templates/{templateId}/pull and writes every file under --dir: text files from the answer, binaries downloaded from their signed links. It replaces an existing file only when an earlier pull wrote it or a push sent it and it has not changed since (${PULL_STATE} in the folder records both), or with --force; other files in the folder are left alone. Every path is checked before anything is written: one that is not a file of the Studio bundle layout (studio.json, template.liquid, fallback.liquid, README.md, brief.md, ideas.md, assets/, samples/), would land outside --dir, or passes through a symbolic link is refused, and so is a samples/ .json that is not one object with only the keys account, person, sender, brand, link, data, role and roles. --template-version picks the version: draft, latest (published) or a version id; the default is the draft, else the latest published version. --dry-run lists the paths, and the files it would not replace, without writing or downloading anything.`,
18818
+ description: `Reads GET /v1/asset-templates/{templateId}/pull and writes every file under --dir: text files from the answer, binaries downloaded from their signed links. It replaces an existing file only when an earlier pull wrote it or a push sent it and it has not changed since (${PULL_STATE} in the folder records both), or with --force; other files in the folder are left alone. Every path is checked before anything is written: one that is not a file of the Studio bundle layout (studio.json, template.liquid, fallback.liquid, README.md, brief.md, ideas.md, assets/, samples/), would land outside --dir, or passes through a symbolic link is refused, and so is a samples/ .json that is not one object with only the keys account, person, sender, brand, link, data, role and roles. Of two paths that differ only by letter case, only the first is written and the other is listed under caseConflicts (macOS and Windows folders would write both to one file); a push with --delete-missing then removes it from the template. --template-version picks the version: draft, latest (published) or a version id; the default is the draft, else the latest published version. --dry-run lists the paths, and the files it would not replace, without writing or downloading anything.`,
18808
18819
  flags: {
18809
18820
  dir: { type: "string", required: true, description: "The folder to write the files to (created when missing)" },
18810
18821
  "template-version": { type: "string", description: "draft, latest or a version id (default: the draft, else the latest published)" },
@@ -18833,8 +18844,15 @@ var init_pull = __esm({
18833
18844
  if (pulled.skipped?.length) {
18834
18845
  ctx.output.warn(`Kenso left out ${pulled.skipped.length} stored file${pulled.skipped.length === 1 ? "" : "s"} that a push would refuse now (outside the bundle layout, a sample .json that does not hold a sample, or a .md file with a tool's config line): ${pulled.skipped.join(", ")}.`);
18835
18846
  }
18836
- const files = Object.entries(pulled.files ?? {}).map(([path, file]) => ({ path, file, target: safeJoin(dir3, path) }));
18837
- for (const { path, file } of files) checkPulledContent(path, file.text);
18847
+ const served = Object.entries(pulled.files ?? {}).map(([path, file]) => ({ path, file, target: safeJoin(dir3, path) }));
18848
+ for (const { path, file } of served) checkPulledContent(path, file.text);
18849
+ const twins = caseTwins(served.map(({ path }) => path));
18850
+ const files = served.filter(({ path }) => !twins.has(path));
18851
+ if (twins.size > 0) {
18852
+ const left = [...twins].map(([path, twin]) => `${path} (differs from ${twin} only by letter case)`).join(", ");
18853
+ ctx.output.warn(`Left out ${left}: on macOS and Windows both would be one file. Push the files you keep with --delete-missing to remove the other from the template.`);
18854
+ }
18855
+ const caseConflicts = twins.size > 0 ? { caseConflicts: [...twins.keys()] } : {};
18838
18856
  const missing2 = files.find(({ file }) => typeof file.text !== "string" && !file.downloadUrl);
18839
18857
  if (missing2) {
18840
18858
  throw new KensoError({ code: "pull_incomplete", message: `${missing2.path} came back with neither text nor a download link.`, exitCode: ExitCode.Server });
@@ -18856,6 +18874,7 @@ var init_pull = __esm({
18856
18874
  versionId: pulled.versionId,
18857
18875
  dir: dir3,
18858
18876
  files: files.map(({ path }) => path),
18877
+ ...caseConflicts,
18859
18878
  ...conflicts.length > 0 ? { conflicts } : {}
18860
18879
  });
18861
18880
  return ExitCode.Ok;
@@ -18878,7 +18897,7 @@ var init_pull = __esm({
18878
18897
  return [path, sha2563(content)];
18879
18898
  });
18880
18899
  await recordPullState(dir3, written);
18881
- ctx.output.object({ templateId, versionId: pulled.versionId, files: files.length, dir: dir3, ...conflicts.length > 0 ? { replaced: conflicts } : {} });
18900
+ ctx.output.object({ templateId, versionId: pulled.versionId, files: files.length, dir: dir3, ...caseConflicts, ...conflicts.length > 0 ? { replaced: conflicts } : {} });
18882
18901
  return ExitCode.Ok;
18883
18902
  }
18884
18903
  };