@nolto/cli 0.15.0 → 0.15.1

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 +31 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -552,7 +552,7 @@ function checkKeys(value, allowed, at, errors) {
552
552
  function isValidPlanPath(value) {
553
553
  if (typeof value !== "string" || value.length === 0) return false;
554
554
  if (value.includes("\\") || value.startsWith("/") || /^[A-Za-z]:/.test(value)) return false;
555
- return value.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
555
+ return /\.(md|markdown)$/i.test(value) && value.split("/").every((segment, index) => segment !== "" && (!segment.startsWith(".") || index === 0 && segment === ".nolto"));
556
556
  }
557
557
  function daysInMonth(year, month) {
558
558
  if (month === 2) {
@@ -593,7 +593,7 @@ function validatePlanPath(value, at) {
593
593
  }
594
594
  if (!isValidPlanPath(value)) {
595
595
  return [
596
- `${at} must be a repository-relative path using '/' separators (no absolute paths, '\\', '.' or '..' segments).`
596
+ `${at} must be a repository-relative path using '/' separators (no absolute paths, '\\', segments starting with '.' except a leading '.nolto/'; Markdown '.md' / '.markdown' only).`
597
597
  ];
598
598
  }
599
599
  return [];
@@ -1103,6 +1103,17 @@ async function loadValidRoadmap(filePath, readFile13) {
1103
1103
  async function buildSyncBody(args) {
1104
1104
  const planDocuments = [];
1105
1105
  for (const ref of collectPlanRefs(args.roadmap)) {
1106
+ if (!isValidPlanPath(ref.path)) {
1107
+ args.deps.warn(`plan path not allowed (markdown only, no dot segments), skipping: ${ref.path}`);
1108
+ continue;
1109
+ }
1110
+ try {
1111
+ if (await args.deps.isIgnored?.(args.repoRoot, ref.path)) {
1112
+ args.deps.warn(`plan path is git-ignored, skipping: ${ref.path}`);
1113
+ continue;
1114
+ }
1115
+ } catch {
1116
+ }
1106
1117
  const root = path3.resolve(args.repoRoot);
1107
1118
  const absolute = path3.resolve(root, ref.path);
1108
1119
  if (absolute !== root && !absolute.startsWith(root + path3.sep)) {
@@ -1127,6 +1138,10 @@ async function buildSyncBody(args) {
1127
1138
  args.deps.warn(`symlink escapes repository root, skipping: ${ref.path}`);
1128
1139
  continue;
1129
1140
  }
1141
+ if (!isValidPlanPath(path3.relative(realRoot, real).split(path3.sep).join("/"))) {
1142
+ args.deps.warn(`plan path not allowed (markdown only, no dot segments), skipping: ${ref.path}`);
1143
+ continue;
1144
+ }
1130
1145
  }
1131
1146
  const content = await args.deps.readFile(absolute);
1132
1147
  planDocuments.push({
@@ -2488,6 +2503,10 @@ function collectContainedPlanAbsPaths(roadmaps, root, warn2) {
2488
2503
  warn2(`chokidar target outside repo, skipping: ${ref.path}`);
2489
2504
  continue;
2490
2505
  }
2506
+ if (!isValidPlanPath(ref.path)) {
2507
+ warn2(`plan path not allowed (markdown only, no dot segments), skipping: ${ref.path}`);
2508
+ continue;
2509
+ }
2491
2510
  planAbsPaths.add(absolute);
2492
2511
  }
2493
2512
  }
@@ -2521,6 +2540,15 @@ async function syncRepo(args, io) {
2521
2540
  roadmaps.push({ slug, ...entry });
2522
2541
  }
2523
2542
  if (roadmaps.length === 0) throw new CliError("No cached roadmap belongs to this repository. Run `nolto link --slug <slug>` to create one, or `nolto pull`.", 2);
2543
+ const exec = io.exec;
2544
+ const isIgnored = exec === void 0 ? void 0 : async (root, relPath) => {
2545
+ try {
2546
+ await exec("git", ["check-ignore", "-q", "--", relPath], { cwd: root });
2547
+ return true;
2548
+ } catch {
2549
+ return false;
2550
+ }
2551
+ };
2524
2552
  const results = [];
2525
2553
  for (const entry of roadmaps) {
2526
2554
  const { slug, roadmap, meta } = entry;
@@ -2528,7 +2556,7 @@ async function syncRepo(args, io) {
2528
2556
  try {
2529
2557
  const response = await runSync(
2530
2558
  { repoRoot: args.root, projectId, slug, roadmap, repoIdentity, baseRevision: meta?.revision ?? 0 },
2531
- { http: io.http, readFile: io.readFile, fileExists: io.fileExists, realpath: io.realpath, log: io.log, warn: io.warn }
2559
+ { http: io.http, readFile: io.readFile, fileExists: io.fileExists, realpath: io.realpath, ...isIgnored ? { isIgnored } : {}, log: io.log, warn: io.warn }
2532
2560
  );
2533
2561
  await writeCache(io.env, projectId, slug, response.roadmap ?? roadmap, {
2534
2562
  repoIdentity: identity,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nolto/cli",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "CLI for syncing repository roadmaps with Nolto.",
5
5
  "license": "MIT",
6
6
  "type": "module",