@biffo/cli 0.324.4 → 0.324.5

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 +26 -23
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9744,24 +9744,25 @@ function readTomlStringArray(text, key) {
9744
9744
  }
9745
9745
  return depth === 0 ? strings : [];
9746
9746
  }
9747
+ function normaliseName(name) {
9748
+ return name.replace(/[-_.]+/g, "-").toLowerCase();
9749
+ }
9747
9750
  function readProjectName(text) {
9748
- let inProject = false;
9749
- for (const line of text.split("\n")) {
9750
- const trimmed = line.trim();
9751
- if (trimmed.startsWith("[")) {
9752
- inProject = trimmed === "[project]";
9753
- continue;
9754
- }
9755
- if (inProject) {
9756
- const m = /^name\s*=\s*["']([^"']+)["']/.exec(trimmed);
9757
- if (m) return m[1];
9758
- }
9751
+ let doc;
9752
+ try {
9753
+ doc = parseToml(text);
9754
+ } catch {
9755
+ return null;
9759
9756
  }
9760
- return null;
9757
+ const name = isTable(doc.project) ? doc.project.name : void 0;
9758
+ return typeof name === "string" && name !== "" ? name : null;
9761
9759
  }
9762
9760
  function requirementName(requirement) {
9763
9761
  return /^\s*([A-Za-z0-9._-]+)/.exec(requirement)?.[1] ?? null;
9764
9762
  }
9763
+ function stringsIn(value) {
9764
+ return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
9765
+ }
9765
9766
  function isTable(value) {
9766
9767
  return typeof value === "object" && value !== null && !Array.isArray(value);
9767
9768
  }
@@ -9853,9 +9854,12 @@ function isSourcesHeader(header) {
9853
9854
  function workspaceMemberNames(instanceRoot) {
9854
9855
  const rootPyproject = join30(instanceRoot, "pyproject.toml");
9855
9856
  if (!existsSync30(rootPyproject)) return /* @__PURE__ */ new Set();
9856
- const text = readFileSync21(rootPyproject, "utf8");
9857
- const members = readTomlStringArray(text, "members");
9858
- const excluded = new Set(readTomlStringArray(text, "exclude"));
9857
+ const doc = parsePyproject(readFileSync21(rootPyproject, "utf8"), rootPyproject);
9858
+ const tool = isTable(doc.tool) ? doc.tool : {};
9859
+ const uv = isTable(tool.uv) ? tool.uv : {};
9860
+ const workspace = isTable(uv.workspace) ? uv.workspace : {};
9861
+ const members = stringsIn(workspace.members);
9862
+ const excluded = new Set(stringsIn(workspace.exclude));
9859
9863
  const dirs = [];
9860
9864
  for (const member of members) {
9861
9865
  if (member.endsWith("/*")) {
@@ -9879,7 +9883,7 @@ function workspaceMemberNames(instanceRoot) {
9879
9883
  const pp = join30(instanceRoot, dir, "pyproject.toml");
9880
9884
  if (!existsSync30(pp)) continue;
9881
9885
  const name = readProjectName(readFileSync21(pp, "utf8"));
9882
- if (name) names.add(name);
9886
+ if (name) names.add(normaliseName(name));
9883
9887
  }
9884
9888
  return names;
9885
9889
  }
@@ -9887,13 +9891,12 @@ function ensureWorkspaceSources(pluginPyprojectPath, memberNames) {
9887
9891
  if (!existsSync30(pluginPyprojectPath) || memberNames.size === 0) return [];
9888
9892
  const text = readFileSync21(pluginPyprojectPath, "utf8");
9889
9893
  const doc = parsePyproject(text, pluginPyprojectPath);
9890
- const already = existingSourceNames(doc);
9891
- const declared = new Set(readDeclaredDependencyNames(doc));
9892
- const toAdd = [...declared].filter((n) => memberNames.has(n) && !already.has(n));
9894
+ const members = new Set([...memberNames].map(normaliseName));
9895
+ const already = new Set([...existingSourceNames(doc)].map(normaliseName));
9896
+ const declared = new Set(readDeclaredDependencyNames(doc).map(normaliseName));
9897
+ const toAdd = [...declared].filter((n) => members.has(n) && !already.has(n));
9893
9898
  if (toAdd.length === 0) return [];
9894
- const lines = toAdd.map(
9895
- (n) => `${/^[A-Za-z0-9_-]+$/.test(n) ? n : JSON.stringify(n)} = { workspace = true }`
9896
- );
9899
+ const lines = toAdd.map((n) => `${n} = { workspace = true }`);
9897
9900
  let updated;
9898
9901
  if (hasSourcesTable(doc)) {
9899
9902
  const insertAt = sourcesHeaderLineEnd(text);
@@ -9916,7 +9919,7 @@ ${lines.join("\n")}
9916
9919
  }
9917
9920
  let written = /* @__PURE__ */ new Set();
9918
9921
  try {
9919
- written = existingSourceNames(parseToml(updated));
9922
+ written = new Set([...existingSourceNames(parseToml(updated))].map(normaliseName));
9920
9923
  } catch {
9921
9924
  }
9922
9925
  const missing = toAdd.filter((n) => !written.has(n));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biffo/cli",
3
- "version": "0.324.4",
3
+ "version": "0.324.5",
4
4
  "description": "Biffo project scaffolding CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",