@nolto/cli 0.26.0 → 0.27.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.
package/README.md CHANGED
@@ -56,6 +56,8 @@ expires (HTTP 401), run `nolto login` again. `nolto whoami` shows the expiry dat
56
56
  and, within 7 days of it, a reminder. The memory hook (`nolto memory pull --hook`)
57
57
  also tells you to run `nolto login` on a 401.
58
58
 
59
+ A token has the `share` scope when it is created by `nolto login` (or issued with "共有" allowed in the settings). The `share` scope is needed to switch what customers see: `--shared` writes and `--audience`. A token created by `nolto login` before the `share` scope was added does not have it; if `nolto whoami` shows no `share` in its scopes, run `nolto login` again to switch sharing. The API answers 403 `token_scope` (`requiredScope: "share"`), and the CLI exits 3 with a hint to log in again.
60
+
59
61
  `nolto logout` asks the server to revoke the saved token (`POST /api/me/token/revoke`),
60
62
  then removes only `token` from the config file (`baseUrl` stays) and clears the
61
63
  memory caches. If the server cannot be reached, does not have the route yet (404),
@@ -268,7 +270,8 @@ References accept a key (NOLTO-12) or number (12). Only the number is sent. With
268
270
  | `issue comment <ref>` | `-m/--comment <text>` or `--body-file <path-or-dash>` |
269
271
  | `issue close <ref>` | `--status <closed-name-or-UUID>`, `-m/--comment <text>` |
270
272
 
271
- - `--shared` on create, update, comment or close writes in shared mode: customers see the text as written. The default is internal. Shared mode is available only in Pro+ projects with customers; other projects fail before any write. It cannot be combined with `create --draft`, `--priority` or `--category`. Human success output adds ` (shared: <audience name>)` to the first line (` (shared)` when the name is not known); JSON responses stay unchanged.
273
+ - `--no-customer-notify` on update or close sends `skipCustomerNotification: true`: this one status change of a shared issue is not notified to the customers watching it (they still see it in the issue's history). Without it, the project's setting (all / only when a closed status is reached / none) decides. It is for the internal write only: combined with `--shared` it exits 2 before any request (the API answers 400 too). It has no effect when the status does not change.
274
+ - `--shared` on create, update, comment or close writes in shared mode: customers see the text as written. The token needs the `share` scope (see Setup and Authentication; tokens from `nolto login` made before the `share` scope was added do not have it; if `nolto whoami` shows no `share`, run `nolto login` again). The default is internal. Shared mode is available only in Pro+ projects with customers; other projects fail before any write. It cannot be combined with `create --draft`, `--priority` or `--category`. Human success output adds ` (shared: <audience name>)` to the first line (` (shared)` when the name is not known); JSON responses stay unchanged.
272
275
  - `--audience <name-or-UUID>` (with `--shared` only; otherwise exit 2) picks the share audience. The CLI reads `GET /api/projects/<id>/audiences` (token scope `issues:read`; exit 3 `共有先の一覧を読めませんでした。` on an old API or a token without it) and matches the name exactly after trimming, or the UUID. No match exits 2 and lists the audiences. Several audiences with the same name (spaces aside), or a UUID that is one audience's id and another's name, exit 2 instead of picking one. It sends `X-Nolto-View: shared; audience=<uuid>`.
273
276
  - Omitted on update, comment or close: the CLI reads the issue in the internal view and uses its audience. An issue that is not shared exits 2 without writing; an issue without an audience id sends `shared` only.
274
277
  - Omitted on create: sends `shared` only. A project with several audiences answers 400 `view_audience_required`; the CLI exits 2 with `共有先が 2 つ以上あります。--audience <名前> で指定してください(候補: …)。` (without the candidates when the audience list cannot be read or has no valid audiences) and nothing is written. The choice is the user's: the error hint says not to guess it from the candidates.
package/dist/index.js CHANGED
@@ -140,6 +140,16 @@ function mapHttpStatusToCliError(status, opts = {}) {
140
140
  const details = Array.isArray(opts.details) ? opts.details.map((detail) => typeof detail === "string" ? detail : JSON.stringify(detail)).join("\n") : "";
141
141
  return new CliError([opts.serverError ?? opts.serverMessage ?? "Validation failed", details].filter(Boolean).join("\n"), 2, void 0, status, opts.serverError, opts.body);
142
142
  }
143
+ if (status === 403 && opts.serverError === "token_scope" && opts.body?.requiredScope === "share") {
144
+ return new CliError(
145
+ opts.serverMessage ?? opts.serverError,
146
+ 3,
147
+ "\u5171\u6709\u3092\u5207\u308A\u66FF\u3048\u308B\u306B\u306F\u3001\u5229\u7528\u8005\u306B\u78BA\u304B\u3081\u3066\u304B\u3089 `nolto login` \u3067\u30ED\u30B0\u30A4\u30F3\u3057\u76F4\u3059\u304B\u3001\u8A2D\u5B9A\u3067\u300C\u5171\u6709\u300D\u3092\u8A31\u53EF\u3057\u305F token \u3092\u767A\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
148
+ status,
149
+ opts.serverError,
150
+ opts.body
151
+ );
152
+ }
143
153
  if (status === 403 && (opts.serverError === "token_scope" || opts.serverError === "token_project")) {
144
154
  return new CliError(
145
155
  opts.serverMessage ?? opts.serverError,
@@ -2903,7 +2913,15 @@ var confirmHelp = "Send even if the text has references customers cannot open. U
2903
2913
  var audienceHint = "\u3069\u306E\u5171\u6709\u5148\u306B\u66F8\u304F\u304B\u306F\u5229\u7528\u8005\u306B\u78BA\u304B\u3081\u308B\u3002\u5019\u88DC\u304B\u3089\u63A8\u6E2C\u3057\u3066 --audience \u3092\u4ED8\u3051\u306A\u3044\u3002";
2904
2914
  var confirmHint = "\u53C2\u7167\u3092\u5916\u3059\u304B\u66F8\u304D\u63DB\u3048\u308B\u306E\u304C\u5148\u3002\u3053\u306E\u307E\u307E\u9001\u308B\u3068\u3001\u3053\u306E\u6587\u9762\u306F\u304A\u5BA2\u3055\u307E\u306B\u305D\u306E\u307E\u307E\u898B\u3048\u3001\u53C2\u7167\u306F\u958B\u3051\u306A\u3044\u307E\u307E\u6B8B\u308B\u3002\u5229\u7528\u8005\u306B\u78BA\u304B\u3081\u3066\u304B\u3089 --confirm-references \u3092\u4ED8\u3051\u3066\u518D\u5B9F\u884C\u3059\u308B";
2905
2915
  function sharedOptions(command) {
2906
- return command.option("--shared", "Write in shared mode (visible to customers). Pro+ projects with customers only.").option("--audience <name-or-id>", "Share audience for --shared (name or UUID). Required on create when the project has several audiences.").option("--confirm-references", confirmHelp);
2916
+ return command.option("--shared", "Write in shared mode (visible to customers). Pro+ projects with customers only. The token needs the share scope.").option("--audience <name-or-id>", "Share audience for --shared (name or UUID). Required on create when the project has several audiences. Like --shared, it needs the share scope.").option("--confirm-references", confirmHelp);
2917
+ }
2918
+ function noCustomerNotifyOption(command) {
2919
+ return command.option("--no-customer-notify", "Do not notify watching customers of this status change of a shared issue (this one time only). Not for --shared.");
2920
+ }
2921
+ function checkNoCustomerNotify(flags) {
2922
+ if (flags.customerNotify !== false) return {};
2923
+ if (flags.shared) throw new CliError("--no-customer-notify \u306F --shared \u3068\u4E00\u7DD2\u306B\u4F7F\u3048\u307E\u305B\u3093(\u5171\u6709\u30E2\u30FC\u30C9\u306E\u66F8\u304D\u8FBC\u307F\u306F\u3001\u304A\u5BA2\u3055\u307E\u306B\u901A\u77E5\u3055\u308C\u307E\u3059)\u3002", 2);
2924
+ return { skipCustomerNotification: true };
2907
2925
  }
2908
2926
  async function checkShared(deps, root, flags, ref) {
2909
2927
  if (flags.audience !== void 0 && !flags.shared) throw new CliError("--audience \u306F --shared \u3068\u4E00\u7DD2\u306B\u4F7F\u3044\u307E\u3059\u3002", 2);
@@ -3168,14 +3186,15 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${fromTemp
3168
3186
  printResult(ctx.mode === "json" ? result : `${result.issue.key} published${project}
3169
3187
  ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${warningLines(result.warnings)}`, ctx.mode);
3170
3188
  });
3171
- writeOptions(group.command("update <ref>").description("Update issue fields."), false).action(async (ref, flags, command) => {
3189
+ noCustomerNotifyOption(writeOptions(group.command("update <ref>").description("Update issue fields."), false)).action(async (ref, flags, command) => {
3172
3190
  const ctx = context(deps, command);
3173
3191
  const number = parseIssueRef(ref);
3192
+ const skip = checkNoCustomerNotify(flags);
3174
3193
  ctx.projectName = await checkShared(deps, ctx.root, flags, ref);
3175
3194
  const { input } = await writeInput(deps, ctx.root, flags, false);
3176
3195
  const { view } = await sharedView(deps, ctx.root, ctx.mode, flags, number);
3177
3196
  const project = await projectLine(deps, ctx);
3178
- const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "patch", `${ctx.root}/issues/${number}`, input, view);
3197
+ const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "patch", `${ctx.root}/issues/${number}`, { ...input, ...skip }, view);
3179
3198
  printResult(ctx.mode === "json" ? result : `${result.issue.key} updated${writeSuffix(flags, view)}${project}
3180
3199
  ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
3181
3200
  });
@@ -3192,15 +3211,16 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.w
3192
3211
  printResult(ctx.mode === "json" ? result : `${issue.key} commented${writeSuffix(flags, view)}${project}
3193
3212
  ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
3194
3213
  });
3195
- sharedOptions(group.command("close <ref>").description("Move an issue to a closed status.").option("--status <name-or-id>", "Closed status (defaults to first by sort order)").option("-m, --comment <text>", "Comment in the same update")).action(async (ref, flags, command) => {
3214
+ noCustomerNotifyOption(sharedOptions(group.command("close <ref>").description("Move an issue to a closed status.").option("--status <name-or-id>", "Closed status (defaults to first by sort order)").option("-m, --comment <text>", "Comment in the same update"))).action(async (ref, flags, command) => {
3196
3215
  const ctx = context(deps, command);
3197
3216
  const number = parseIssueRef(ref);
3217
+ const skip = checkNoCustomerNotify(flags);
3198
3218
  ctx.projectName = await checkShared(deps, ctx.root, flags, ref);
3199
3219
  const settings = await deps.http.get(`${ctx.root}/issue-settings`);
3200
3220
  const status = pickClosedStatus(settings, flags.status);
3201
3221
  const { view } = await sharedView(deps, ctx.root, ctx.mode, flags, number);
3202
3222
  const project = await projectLine(deps, ctx);
3203
- const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "patch", `${ctx.root}/issues/${number}`, { statusId: status.id, ...flags.comment !== void 0 ? { comment: flags.comment } : {} }, view);
3223
+ const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "patch", `${ctx.root}/issues/${number}`, { statusId: status.id, ...flags.comment !== void 0 ? { comment: flags.comment } : {}, ...skip }, view);
3204
3224
  printResult(ctx.mode === "json" ? result : `${result.issue.key} closed${writeSuffix(flags, view)}${project}
3205
3225
  ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
3206
3226
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nolto/cli",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "CLI for syncing repository roadmaps with Nolto.",
5
5
  "license": "MIT",
6
6
  "type": "module",