@nolto/cli 0.16.0 → 0.17.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 (3) hide show
  1. package/README.md +3 -0
  2. package/dist/index.js +33 -13
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -22,6 +22,9 @@ nolto init
22
22
  repo-local `nolto.json` binding, installs the bundled `roadmap-progress` skill,
23
23
  and pulls roadmaps into the project cache. If the server has none, it creates a
24
24
  schema v3 roadmap on the server. `nolto link` also pulls or creates roadmaps.
25
+
26
+ When creating a project, `nolto init` uses your only eligible organization automatically, or asks you to select one by number when several are available. If none are available, create an organization at `<baseURL>/orgs/new` first. Projects are always created in an organization.
27
+
25
28
  Re-running it inside a repository keeps the saved token and only sets up that
26
29
  repository; use `--force` to reconfigure the global settings.
27
30
 
package/dist/index.js CHANGED
@@ -2073,7 +2073,7 @@ function getCliVersion() {
2073
2073
  }
2074
2074
  return "0.0.0";
2075
2075
  }
2076
- async function pickProject(rl, http, projects, promptText) {
2076
+ async function pickProject(rl, http, projects, promptText, baseUrl) {
2077
2077
  if (projects.length > 0) {
2078
2078
  process.stdout.write("\nProjects:\n");
2079
2079
  projects.forEach((project, index) => {
@@ -2090,9 +2090,27 @@ async function pickProject(rl, http, projects, promptText) {
2090
2090
  if (name.trim().length === 0) {
2091
2091
  throw new CliError("Project name is required.", 2);
2092
2092
  }
2093
+ const { orgs } = await http.get("/api/orgs/eligible");
2094
+ if (orgs.length === 0) {
2095
+ throw new CliError(`No organization to create the project in. Create one at ${baseUrl.replace(/\/+$/, "")}/orgs/new first.`, 2);
2096
+ }
2097
+ let organization = orgs[0];
2098
+ if (orgs.length > 1) {
2099
+ process.stdout.write("\nOrganizations:\n");
2100
+ orgs.forEach((org, index2) => {
2101
+ process.stdout.write(` (${index2 + 1}) ${org.name} \u2014 ${org.id}
2102
+ `);
2103
+ });
2104
+ const choice = (await rl.question("Organization number: ")).trim();
2105
+ const index = Number(choice);
2106
+ if (!/^\d+$/.test(choice) || !Number.isSafeInteger(index) || index < 1 || index > orgs.length) {
2107
+ throw new CliError("Invalid organization number.", 2);
2108
+ }
2109
+ organization = orgs[index - 1];
2110
+ }
2093
2111
  const created = await http.post(
2094
2112
  "/api/projects",
2095
- { name: name.trim() }
2113
+ { name: name.trim(), orgId: organization.id }
2096
2114
  );
2097
2115
  if (created.project?.id == null) {
2098
2116
  throw new CliError("Project API did not return a project id.", 2);
@@ -2101,7 +2119,7 @@ async function pickProject(rl, http, projects, promptText) {
2101
2119
  id: created.project.id,
2102
2120
  name: created.project.name ?? name.trim()
2103
2121
  };
2104
- process.stdout.write(`Created project ${project.name} (${project.id})
2122
+ process.stdout.write(`Created project ${project.name} (${project.id}) in ${organization.name}
2105
2123
  `);
2106
2124
  return project;
2107
2125
  }
@@ -2111,7 +2129,7 @@ async function pickProject(rl, http, projects, promptText) {
2111
2129
  }
2112
2130
  return void 0;
2113
2131
  }
2114
- async function selectRepoProject(rl, http, projects, defaultProjectId) {
2132
+ async function selectRepoProject(rl, http, projects, defaultProjectId, baseUrl) {
2115
2133
  const defaultProject = defaultProjectId == null ? void 0 : projects.find((project) => project.id === defaultProjectId);
2116
2134
  if (defaultProject != null) {
2117
2135
  const useDefault = await rl.question(
@@ -2125,7 +2143,8 @@ async function selectRepoProject(rl, http, projects, defaultProjectId) {
2125
2143
  rl,
2126
2144
  http,
2127
2145
  projects,
2128
- "Project number for this repository, 'c' to create new (or Enter to skip): "
2146
+ "Project number for this repository, 'c' to create new (or Enter to skip): ",
2147
+ baseUrl
2129
2148
  );
2130
2149
  }
2131
2150
  function register3(program, deps) {
@@ -2183,7 +2202,8 @@ function register3(program, deps) {
2183
2202
  rl,
2184
2203
  http,
2185
2204
  projects,
2186
- "Default project number, 'c' to create new (or Enter to skip): "
2205
+ "Default project number, 'c' to create new (or Enter to skip): ",
2206
+ baseUrl
2187
2207
  );
2188
2208
  defaultProjectId = selected?.id;
2189
2209
  defaultProjectName = selected?.name;
@@ -2252,9 +2272,9 @@ Saved ${configPath}
2252
2272
  boundProject != null ? "Keep this binding? [Y/n] " : "Keep this binding? [y/N] "
2253
2273
  );
2254
2274
  keepExistingBinding = boundProject != null ? keep.trim().toLowerCase() !== "n" : keep.trim().toLowerCase() === "y";
2255
- repoProject = keepExistingBinding ? boundProject ?? { id: existingBinding.projectId, name: path12.basename(root) } : await selectRepoProject(rl, repoHttp, projects, defaultProjectId);
2275
+ repoProject = keepExistingBinding ? boundProject ?? { id: existingBinding.projectId, name: path12.basename(root) } : await selectRepoProject(rl, repoHttp, projects, defaultProjectId, baseUrl);
2256
2276
  } else {
2257
- repoProject = await selectRepoProject(rl, repoHttp, projects, defaultProjectId);
2277
+ repoProject = await selectRepoProject(rl, repoHttp, projects, defaultProjectId, baseUrl);
2258
2278
  }
2259
2279
  if (repoProject == null) {
2260
2280
  process.stdout.write("Skipped repo setup (no project selected).\n");
@@ -3071,12 +3091,12 @@ async function roadmapStatus(deps, slug, fresh = false) {
3071
3091
  const { roadmap, meta } = entry;
3072
3092
  const stats = deriveTaskStats(roadmap);
3073
3093
  const tasks = roadmap.phases.flatMap((phase) => phase.tasks);
3074
- const current = tasks.find((task) => task.id === meta?.currentTaskId);
3094
+ const current = tasks.find((task) => task.id === meta?.currentTaskId && task.status === "in-progress");
3075
3095
  const blocked = tasks.filter((task) => task.status === "blocked");
3076
3096
  const age = meta ? (Date.now() - Date.parse(meta.pulledAt)) / 6e4 : NaN;
3077
3097
  if (age > 10) warn(`Warning: cache is ${Math.floor(age)} minutes old; run with --fresh or nolto roadmap pull`);
3078
3098
  if (deps.output.mode === "json") {
3079
- printResult({ roadmap, stats, currentTaskId: meta?.currentTaskId ?? null, revision: meta?.revision ?? 0, pulledAt: meta?.pulledAt ?? null }, "json");
3099
+ printResult({ roadmap, stats, currentTaskId: current?.id ?? null, revision: meta?.revision ?? 0, pulledAt: meta?.pulledAt ?? null }, "json");
3080
3100
  return;
3081
3101
  }
3082
3102
  printResult([
@@ -3257,9 +3277,9 @@ function register9(program, deps) {
3257
3277
  roadmap.command("summary [slug]").description("Replace the summary and sync").requiredOption("--text <text>", "New summary").action((slug, opts) => roadmapSummary(deps, slug, opts.text));
3258
3278
  const bodies = {
3259
3279
  start: { status: "in-progress", currentTask: true },
3260
- done: { status: "done" },
3261
- block: { status: "blocked" },
3262
- todo: { status: "todo", startedAt: null, completedAt: null }
3280
+ done: { status: "done", currentTask: false },
3281
+ block: { status: "blocked", currentTask: false },
3282
+ todo: { status: "todo", currentTask: false, startedAt: null, completedAt: null }
3263
3283
  };
3264
3284
  for (const [name, body] of Object.entries(bodies)) {
3265
3285
  const command = roadmap.command(`${name} <task>`).description(`Set task status to ${body.status}`).option("--slug <slug>", "Roadmap slug (required with multiple cached roadmaps)");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nolto/cli",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "CLI for syncing repository roadmaps with Nolto.",
5
5
  "license": "MIT",
6
6
  "type": "module",