@commentkit/comment-kit 2.0.0 → 2.1.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/CHANGELOG.md +57 -0
- package/README.md +123 -19
- package/SECURITY.md +2 -2
- package/dist/node/cli/api.js +61 -15
- package/dist/node/cli/credentials.js +8 -0
- package/dist/node/cli/doctor.js +152 -25
- package/dist/node/cli/init.js +349 -35
- package/dist/node/cli/main.js +310 -69
- package/dist/node/cli/mcp.js +187 -6
- package/dist/node/cli/website.js +140 -0
- package/dist/node/shared/dashboard-places.js +33 -0
- package/dist/node/types/next.d.ts +4 -4
- package/dist/npm/THIRD_PARTY_NOTICES.txt +47 -0
- package/dist/npm/chunks/{AgentSend-DxRJIYiz.js → AgentSend-pA7Ufvye.js} +16 -16
- package/dist/npm/chunks/Checklist-Cn9skOYK.js +269 -0
- package/dist/npm/chunks/Composer-D7H-pzGa.js +734 -0
- package/dist/npm/chunks/DatePicker-Nta5a1xD.js +161 -0
- package/dist/npm/chunks/{Guest-vvNPz8h-.js → Guest-Bi7hlzhs.js} +63 -59
- package/dist/npm/chunks/{MarkupEditor-VCOXh9d2.js → MarkupEditor-WU3USeTk.js} +46 -39
- package/dist/npm/chunks/Panel-DhAzbUbC.js +1210 -0
- package/dist/npm/chunks/{Settings-BGoZS2iV.js → Settings-BmKqPX40.js} +91 -90
- package/dist/npm/chunks/{Shortcuts-B2OMvczr.js → Shortcuts-Bl-c0Sez.js} +25 -23
- package/dist/npm/chunks/SignInFirst-CmGvSYkQ.js +35 -0
- package/dist/npm/chunks/{StyleEditor-CJ_d8Huf.js → StyleEditor-D6fUnlwq.js} +10 -10
- package/dist/npm/chunks/{StylePanel-yQzHHlY7.js → StylePanel-C-Gikxt1.js} +61 -61
- package/dist/npm/chunks/TaskFields-CaKi523b.js +617 -0
- package/dist/npm/chunks/ThreadCard-d_3pUB5V.js +1142 -0
- package/dist/npm/chunks/Viewer-BULQsi9-.js +115 -0
- package/dist/npm/chunks/{agent-C1OQzBAm.js → agent-DHdhIJ3s.js} +1 -1
- package/dist/npm/chunks/{ar-CAJ3XT8e.js → ar-B5UszrQp.js} +53 -12
- package/dist/npm/chunks/card-bits-cV8GdFWX.js +55 -0
- package/dist/npm/chunks/{client-kNAo2TTG.js → client-Cv8ddtuM.js} +13 -11
- package/dist/npm/chunks/{confetti-CkBdSu19.js → confetti-B9zlyILU.js} +1 -1
- package/dist/npm/chunks/{context-B8UAzve0.js → context-CsHnabaA.js} +1 -1
- package/dist/npm/chunks/{de-Dl18G48t.js → de-BE0Aaq8u.js} +53 -12
- package/dist/npm/chunks/{dialog-GO04oC3D.js → dialog-DvdIkCW0.js} +1 -1
- package/dist/npm/chunks/{dpop-U48QIQd7.js → dpop-CwW9ifkq.js} +1 -1
- package/dist/npm/chunks/entrance-Bn_5M9uO.js +90 -0
- package/dist/npm/chunks/{es-Dxk79lS9.js → es-BQviao4d.js} +53 -12
- package/dist/npm/chunks/{extension-E81hWyiT.js → extension-CnQTDC1j.js} +2 -2
- package/dist/npm/chunks/{extension-CKFpPWmi.js → extension-DXhz81XD.js} +1 -1
- package/dist/npm/chunks/{files-DyD5BZgp.js → files-DLEr_wmh.js} +2 -2
- package/dist/npm/chunks/{fr-8BebGKYD.js → fr-C5gu6A06.js} +53 -12
- package/dist/npm/chunks/{hi-BIN6Yy_p.js → hi-DXfQ5EvY.js} +53 -12
- package/dist/npm/chunks/{i18n-DOBt8e9U.js → i18n-Mgs9VOuk.js} +63 -58
- package/dist/npm/chunks/icons-_C6ZWmBY.js +141 -0
- package/dist/npm/chunks/{identify-CN-3xzqL.js → identify-BnQGJOa0.js} +4 -4
- package/dist/npm/chunks/{it-Cr6EwpPQ.js → it-BPHt13FV.js} +53 -12
- package/dist/npm/chunks/{ja-Iy3s5aur.js → ja-BkCqyKR0.js} +52 -11
- package/dist/npm/chunks/late-words-D4Oo_yhJ.js +57 -0
- package/dist/npm/chunks/{live-CelVeZfP.js → live-DXcxj_Af.js} +28 -22
- package/dist/npm/chunks/{nl-B84WHqqe.js → nl-DZxdLLMU.js} +53 -12
- package/dist/npm/chunks/{page-key-DepmJzC1.js → page-key-UqAozdZi.js} +1 -1
- package/dist/npm/chunks/{pick-yTyqtxN0.js → pick-C20RVUas.js} +1 -1
- package/dist/npm/chunks/{pkce-ChKGSW_4.js → pkce-BPvWoBrr.js} +1 -1
- package/dist/npm/chunks/{pt-BR-DOkdlfoe.js → pt-BR-lA9mJ05F.js} +53 -12
- package/dist/npm/chunks/{report-CrIqQZDI.js → report-BjUgUNnT.js} +1 -1
- package/dist/npm/chunks/show-BinoJyED.js +97 -0
- package/dist/npm/chunks/signin-C2jjsxz9.js +101 -0
- package/dist/npm/chunks/{source-pXVve2Cx.js → source-NuflODx3.js} +1 -1
- package/dist/npm/chunks/src-9o2Ocq8d.js +221 -0
- package/dist/npm/chunks/start-Cbx6rMrr.js +1904 -0
- package/dist/npm/chunks/states-DLMCvwes.js +3 -0
- package/dist/npm/chunks/{upload-MgPYqPyE.js → upload-C4NpM-jE.js} +1 -1
- package/dist/npm/chunks/uploads-CY4bDbaI.js +1236 -0
- package/dist/npm/chunks/{wrap-Bl0gbnFa.js → wrap-D-xTKIzj.js} +20 -20
- package/dist/npm/chunks/{zh-CN-Z5fQCb7G.js → zh-CN-yqaDHwBx.js} +53 -12
- package/dist/npm/element.js +7 -1
- package/dist/npm/headless.js +2 -2
- package/dist/npm/index.js +2 -2
- package/dist/npm/react.js +1 -1
- package/dist/npm/svelte.js +1 -1
- package/dist/npm/types/adapters/vue.d.ts +12 -0
- package/dist/npm/types/core/auth.d.ts +1 -0
- package/dist/npm/types/core/client.d.ts +5 -1
- package/dist/npm/types/core/types.d.ts +19 -4
- package/dist/npm/vue.js +5 -1
- package/package.json +4 -1
- package/dist/npm/chunks/Checklist-CnlfeSbc.js +0 -282
- package/dist/npm/chunks/Composer-B1bBVszY.js +0 -725
- package/dist/npm/chunks/Panel-F37vIL1K.js +0 -1206
- package/dist/npm/chunks/TaskFields-fmy6_HtK.js +0 -289
- package/dist/npm/chunks/ThreadCard-D51slKST.js +0 -1113
- package/dist/npm/chunks/Viewer-BOBadqmC.js +0 -111
- package/dist/npm/chunks/card-bits-CAnzrqx3.js +0 -53
- package/dist/npm/chunks/late-words-B2bmZceJ.js +0 -12
- package/dist/npm/chunks/show-BgVC8gWY.js +0 -97
- package/dist/npm/chunks/signin-Dd1rb2BP.js +0 -75
- package/dist/npm/chunks/src-BTMy4Gyc.js +0 -208
- package/dist/npm/chunks/start-DtVlpt7p.js +0 -1878
- package/dist/npm/chunks/states-sfTbjZz8.js +0 -3
- package/dist/npm/chunks/uploads-D49mywwz.js +0 -1146
package/dist/node/cli/main.js
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
// The `commentkit` command.
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
3
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
5
5
|
import { createInterface } from "node:readline/promises";
|
|
6
6
|
import { parseArgs } from "node:util";
|
|
7
|
-
import { CliError, endpointFrom, pollDevice, Project, registerClient, SIGN_IN_AGAIN, startDevice } from "./api.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { CliError, Connection, endpointFrom, pollDevice, Project, registerClient, SIGN_IN_AGAIN, startDevice } from "./api.js";
|
|
8
|
+
import { DASHBOARD } from "../shared/dashboard-places.js";
|
|
9
|
+
import { forget, load, save, signInTarget } from "./credentials.js";
|
|
10
|
+
import { clean, CLI, doctor, render } from "./doctor.js";
|
|
10
11
|
import { feedbackMarkdown } from "./format.js";
|
|
11
|
-
import { ignoreFolder, plan, setEnv } from "./init.js";
|
|
12
|
-
import { AGENTS, backup, configPath, DEFAULT_SCOPE, entry, mergeJson, mergeToml, NEXT_STEP, readIfExists, writeAtomic } from "./mcp.js";
|
|
12
|
+
import { describePlace, ignoreFolder, plan, PLUGIN_NODE_NOTE, setEnv } from "./init.js";
|
|
13
|
+
import { AGENTS, backup, configPath, DEFAULT_SCOPE, entry, gitPlace, mergeJson, mergeToml, NEXT_STEP, readIfExists, writeAtomic } from "./mcp.js";
|
|
13
14
|
import { openUrl } from "./open.js";
|
|
15
|
+
import { CHOOSE, chooseWebsite, describeChoice, findFolderChoice, folderChoiceText, FOLDER_FILE, matching, named, websiteWithKey, writeFolderChoice } from "./website.js";
|
|
14
16
|
/** The publishable key format; a test keeps it equal to the pattern in contract/openapi-v1.yaml. */
|
|
15
17
|
export const PUBLISHABLE_KEY = /^pk_(live|test)_[a-z0-9]{20,40}$/;
|
|
16
18
|
const HELP = `CommentKit in your terminal.
|
|
17
19
|
|
|
18
20
|
Usage: npx @commentkit/comment-kit <command> [options]
|
|
19
21
|
|
|
20
|
-
login Sign in with your browser
|
|
22
|
+
login Sign in with your browser: one website, or all websites in a workspace
|
|
21
23
|
logout Forget the sign-in on this computer
|
|
22
|
-
status Show
|
|
24
|
+
status Show the sign-in and which website this folder uses
|
|
25
|
+
websites List the websites the sign-in reaches
|
|
26
|
+
use [website] Choose the website for this folder (by id or name)
|
|
23
27
|
init Add the key, the build plugin and the widget to your app
|
|
24
28
|
doctor [url] Find out why the widget is not showing (this folder and your site)
|
|
25
29
|
pull Save open feedback and tasks to .commentkit/feedback.md
|
|
@@ -35,10 +39,13 @@ Options:
|
|
|
35
39
|
--key <pk_…> (init, doctor) Use this project key without signing in
|
|
36
40
|
--all (pull) Include resolved feedback
|
|
37
41
|
--out <file> (pull) Where to write (default .commentkit/feedback.md)
|
|
38
|
-
--json (pull, token list, status, doctor) Print JSON
|
|
42
|
+
--json (pull, token list, status, doctor, websites) Print JSON
|
|
39
43
|
--reply, --status (token create) Let the token reply / mark ready for review
|
|
40
44
|
--days <n> (token create) Days until it expires (default 30, up to 90)
|
|
41
45
|
|
|
46
|
+
Which website a command uses: COMMENTKIT_PROJECT_ID (with COMMENTKIT_TOKEN), else the
|
|
47
|
+
folder's choice (use), else the publishable key in the folder, else the sign-in's only website.
|
|
48
|
+
|
|
42
49
|
CI: set COMMENTKIT_TOKEN and COMMENTKIT_PROJECT_ID instead of logging in.
|
|
43
50
|
Another server: set COMMENTKIT_ENDPOINT (default https://commentkit.dev).
|
|
44
51
|
`;
|
|
@@ -46,25 +53,45 @@ const COMMAND_HELP = {
|
|
|
46
53
|
login: `Usage: npx @commentkit/comment-kit login [--no-browser] [--scopes read,reply,status]
|
|
47
54
|
|
|
48
55
|
Shows a short code and opens CommentKit in your browser. Confirm the code, then choose
|
|
49
|
-
|
|
56
|
+
one website or all websites in a workspace (including websites added later), and what
|
|
57
|
+
the CLI may do. With a workspace, each code folder uses one website: see use.
|
|
50
58
|
|
|
51
59
|
--no-browser Print the link instead of opening it
|
|
52
60
|
--scopes <list> What to ask for (default read,reply,status)`,
|
|
53
61
|
logout: `Usage: npx @commentkit/comment-kit logout
|
|
54
62
|
|
|
55
63
|
Forgets the sign-in on this computer. To end it on the server too, disconnect it in
|
|
56
|
-
CommentKit
|
|
64
|
+
CommentKit, in Settings → Security, under Connected coding agents.`,
|
|
57
65
|
status: `Usage: npx @commentkit/comment-kit status [--json]
|
|
58
66
|
|
|
59
|
-
|
|
60
|
-
|
|
67
|
+
What this computer is signed in to (one website, or all websites in a workspace), which
|
|
68
|
+
website this folder uses and how it was chosen, what the CLI may do, and whether agent
|
|
69
|
+
changes wait for a person's approval.
|
|
70
|
+
|
|
71
|
+
--json Print JSON`,
|
|
72
|
+
websites: `Usage: npx @commentkit/comment-kit websites [--json]
|
|
73
|
+
|
|
74
|
+
Lists the websites the sign-in reaches: name, address and id. The one this folder uses is
|
|
75
|
+
marked.
|
|
61
76
|
|
|
62
77
|
--json Print JSON`,
|
|
78
|
+
use: `Usage: npx @commentkit/comment-kit use [website]
|
|
79
|
+
|
|
80
|
+
Chooses the website this folder uses, by id or exact name (any case). Without one, shows a
|
|
81
|
+
numbered list to choose from. Saved in .commentkit/project.json, for this folder on this
|
|
82
|
+
computer (.commentkit/ is not committed).
|
|
83
|
+
|
|
84
|
+
Which website a command uses, first match wins:
|
|
85
|
+
1. COMMENTKIT_PROJECT_ID, with COMMENTKIT_TOKEN
|
|
86
|
+
2. .commentkit/project.json in this folder or a parent (this command)
|
|
87
|
+
3. the publishable key in this folder (env file, entry file, script tag)
|
|
88
|
+
4. the sign-in's only website`,
|
|
63
89
|
init: `Usage: npx @commentkit/comment-kit init [--yes] [--dry-run] [--install] [--key pk_…]
|
|
64
90
|
|
|
65
|
-
Finds your framework (Next.js, Vite, SvelteKit, Astro, Nuxt or a plain website) and
|
|
66
|
-
CommentKit up: the key in your env file
|
|
67
|
-
.gitignore, and the widget in your layout or entry file.
|
|
91
|
+
Finds your framework (Next.js, Vite, SvelteKit, Astro, Nuxt, Laravel or a plain website) and
|
|
92
|
+
sets CommentKit up: the key in your env file (Laravel: in the entry, as the default), the build
|
|
93
|
+
plugin in your config, .commentkit/ in .gitignore, and the widget in your layout or entry file.
|
|
94
|
+
Asks before each change.
|
|
68
95
|
|
|
69
96
|
--yes, -y Make every change without asking
|
|
70
97
|
--dry-run Show what would change, change nothing
|
|
@@ -83,20 +110,22 @@ Exits 0 when nothing is wrong, 1 when something is.
|
|
|
83
110
|
--json Print the result as JSON`,
|
|
84
111
|
pull: `Usage: npx @commentkit/comment-kit pull [--all] [--out <file>] [--json]
|
|
85
112
|
|
|
86
|
-
Saves open feedback and tasks to .commentkit/feedback.md
|
|
87
|
-
text is fenced as untrusted content.
|
|
113
|
+
Saves open feedback and tasks of the website this folder uses to .commentkit/feedback.md
|
|
114
|
+
for your coding agent. Reviewer text is fenced as untrusted content.
|
|
88
115
|
|
|
89
116
|
--all Include resolved feedback
|
|
90
117
|
--out <file> Where to write (default .commentkit/feedback.md)
|
|
91
118
|
--json Print JSON instead`,
|
|
92
119
|
open: `Usage: npx @commentkit/comment-kit open [CK-12]
|
|
93
120
|
|
|
94
|
-
Opens the task in your browser, or the task board without a reference
|
|
121
|
+
Opens the task in your browser, or the task board without a reference, for the website
|
|
122
|
+
this folder uses.`,
|
|
95
123
|
token: `Usage: npx @commentkit/comment-kit token list [--json]
|
|
96
124
|
npx @commentkit/comment-kit token create "<name>" [--reply] [--status] [--days <n>]
|
|
97
125
|
npx @commentkit/comment-kit token revoke <id>
|
|
98
126
|
|
|
99
|
-
Tokens for CI (COMMENTKIT_TOKEN), never with more permissions than your sign-in.
|
|
127
|
+
Tokens for CI (COMMENTKIT_TOKEN), never with more permissions than your sign-in. A token is
|
|
128
|
+
for one website: the one this folder uses (see npx @commentkit/comment-kit status).
|
|
100
129
|
|
|
101
130
|
--reply Let the token reply to feedback
|
|
102
131
|
--status Let the token mark feedback ready for review and link commits
|
|
@@ -105,8 +134,8 @@ Tokens for CI (COMMENTKIT_TOKEN), never with more permissions than your sign-in.
|
|
|
105
134
|
mcp: `Usage: npx @commentkit/comment-kit mcp install <cursor|vscode|claude|codex> [--scope user|project] [--dry-run] [--yes]
|
|
106
135
|
|
|
107
136
|
Adds the hosted CommentKit MCP server (https://commentkit.dev/mcp) to your coding agent's
|
|
108
|
-
config file. Nothing else in the file changes
|
|
109
|
-
you to sign in the first time.
|
|
137
|
+
config file. Nothing else in the file changes (its indentation and last newline stay), and it
|
|
138
|
+
is backed up first. Your agent asks you to sign in the first time.
|
|
110
139
|
|
|
111
140
|
cursor ~/.cursor/mcp.json (--scope project: .cursor/mcp.json)
|
|
112
141
|
vscode .vscode/mcp.json (--scope user: your VS Code profile's mcp.json)
|
|
@@ -139,7 +168,11 @@ export async function main(argv, out = console_, cwd = process.cwd()) {
|
|
|
139
168
|
return await logout(out);
|
|
140
169
|
case "status":
|
|
141
170
|
case "whoami":
|
|
142
|
-
return await status(rest, out);
|
|
171
|
+
return await status(rest, out, cwd);
|
|
172
|
+
case "websites":
|
|
173
|
+
return await websites(rest, out, cwd);
|
|
174
|
+
case "use":
|
|
175
|
+
return await use(rest, out, cwd);
|
|
143
176
|
case "init":
|
|
144
177
|
return await init(rest, out, cwd);
|
|
145
178
|
case "pull":
|
|
@@ -147,10 +180,10 @@ export async function main(argv, out = console_, cwd = process.cwd()) {
|
|
|
147
180
|
case "doctor":
|
|
148
181
|
return await runDoctor(rest, out, cwd);
|
|
149
182
|
case "open":
|
|
150
|
-
return await open(rest, out);
|
|
183
|
+
return await open(rest, out, cwd);
|
|
151
184
|
case "token":
|
|
152
185
|
case "tokens":
|
|
153
|
-
return await token(rest, out);
|
|
186
|
+
return await token(rest, out, cwd);
|
|
154
187
|
case "mcp":
|
|
155
188
|
return await mcp(rest, out, cwd);
|
|
156
189
|
case "--version":
|
|
@@ -169,7 +202,8 @@ export async function main(argv, out = console_, cwd = process.cwd()) {
|
|
|
169
202
|
return 2;
|
|
170
203
|
}
|
|
171
204
|
out.error(error instanceof CliError || error instanceof Error ? `Error: ${error.message}` : String(error));
|
|
172
|
-
|
|
205
|
+
// Not knowing which website to use is a usage mistake, like a missing argument.
|
|
206
|
+
return error instanceof CliError && error.code === CHOOSE ? 2 : 1;
|
|
173
207
|
}
|
|
174
208
|
}
|
|
175
209
|
function version() {
|
|
@@ -191,7 +225,9 @@ async function login(args, out) {
|
|
|
191
225
|
await save(endpoint, { client_id: clientId });
|
|
192
226
|
}
|
|
193
227
|
const wanted = (values.scopes ?? "read,reply,status").split(",").map((s) => s.trim()).filter(Boolean);
|
|
194
|
-
|
|
228
|
+
// `workspace` is not a permission: it tells CommentKit this CLI understands a sign-in for every website of a
|
|
229
|
+
// workspace, so the browser offers that choice next to one website (which stays the default).
|
|
230
|
+
const scope = ["feedback:read", ...wanted.filter((s) => s !== "read").map((s) => `feedback:${s}`), "workspace"].join(" ");
|
|
195
231
|
let device;
|
|
196
232
|
try {
|
|
197
233
|
device = await startDevice(endpoint, clientId, scope);
|
|
@@ -208,7 +244,7 @@ async function login(args, out) {
|
|
|
208
244
|
// Only the plain page is opened: a link with the code already in it is a phishing path (someone could send
|
|
209
245
|
// their own link), so the person types the code they see here. Never a URL built with the code.
|
|
210
246
|
out.log(`\nYour code: ${device.user_code}\n`);
|
|
211
|
-
out.log(`Type this code on ${device.verification_uri}, then choose
|
|
247
|
+
out.log(`Type this code on ${device.verification_uri}, then choose one website or all websites in a workspace.`);
|
|
212
248
|
if (!values["no-browser"] && (await openUrl(device.verification_uri)))
|
|
213
249
|
out.log("(Opened that page in your browser.)");
|
|
214
250
|
out.log("Waiting for you to confirm…");
|
|
@@ -236,19 +272,28 @@ async function login(args, out) {
|
|
|
236
272
|
throw new CliError("The code expired before it was confirmed. Run npx @commentkit/comment-kit login again.");
|
|
237
273
|
}
|
|
238
274
|
async function finishLogin(endpoint, clientId, answer, out) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
project_id:
|
|
248
|
-
project_name: answer.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
275
|
+
const tokens = { client_id: clientId, access_token: answer.access_token, refresh_token: answer.refresh_token, expires_at: Date.now() + answer.expires_in * 1000, scope: answer.scope };
|
|
276
|
+
if (answer.project?.id) {
|
|
277
|
+
// The workspace fields are cleared: an older sign-in's would otherwise stay next to this one.
|
|
278
|
+
await save(endpoint, { ...tokens, project_id: answer.project.id, project_name: answer.project.name, workspace_id: null, workspace_name: null });
|
|
279
|
+
out.log(`\nSigned in. Project: ${clean(answer.project.name, 80)}. Allowed: ${permissions(answer.scope)}.`);
|
|
280
|
+
return 0;
|
|
281
|
+
}
|
|
282
|
+
if (answer.workspace?.id) {
|
|
283
|
+
// project_id null: CLI 2.0.x reads it and answers "You are not signed in. Run login", never a wrong website.
|
|
284
|
+
await save(endpoint, { ...tokens, project_id: null, project_name: null, workspace_id: answer.workspace.id, workspace_name: answer.workspace.name });
|
|
285
|
+
out.log(`\nSigned in to all websites in “${clean(answer.workspace.name, 80)}”, including websites added later. Allowed: ${permissions(answer.scope)}.`);
|
|
286
|
+
try {
|
|
287
|
+
const list = await (await Connection.open(endpoint)).projects();
|
|
288
|
+
out.log(list.length ? `It reaches ${list.length} website${list.length === 1 ? "" : "s"}: ${list.slice(0, 5).map((p) => clean(p.name, 40)).join(", ")}${list.length > 5 ? ` and ${list.length - 5} more` : ""}.` : "It reaches no website right now.");
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
// The list is a convenience here; websites shows it (and any error) later.
|
|
292
|
+
}
|
|
293
|
+
out.log(`Each code folder uses one website: the one whose publishable key is in the folder, or the one you choose there with ${CLI} use.`);
|
|
294
|
+
return 0;
|
|
295
|
+
}
|
|
296
|
+
throw new CliError("Signed in, but CommentKit did not say which website or workspace was chosen. Update the CLI and try again.");
|
|
252
297
|
}
|
|
253
298
|
function permissions(scope) {
|
|
254
299
|
const parts = scope.split(" ");
|
|
@@ -258,27 +303,158 @@ async function logout(out) {
|
|
|
258
303
|
// CommentKit has no endpoint yet for a terminal sign-in to end itself, so this is local only.
|
|
259
304
|
const had = await forget(endpointFrom());
|
|
260
305
|
out.log(had
|
|
261
|
-
?
|
|
306
|
+
? `Signed out on this computer. The sign-in still works on the server until it expires (30 days unused); to end it now, disconnect it in CommentKit, in ${DASHBOARD.connectedAgents}.`
|
|
262
307
|
: "You were not signed in.");
|
|
263
308
|
return 0;
|
|
264
309
|
}
|
|
265
|
-
|
|
310
|
+
/** Errors that mean "this folder has no usable website choice", which status and websites report instead of stopping. */
|
|
311
|
+
function choiceProblem(error) {
|
|
312
|
+
return error instanceof CliError && [CHOOSE, "folder_choice", "no_website"].includes(error.code);
|
|
313
|
+
}
|
|
314
|
+
/** What the credentials in use are for, in plain words. */
|
|
315
|
+
function describeAccess(connection) {
|
|
316
|
+
const access = connection.access;
|
|
317
|
+
if (access.kind === "token")
|
|
318
|
+
return `a CI token (COMMENTKIT_TOKEN) for website ${access.projectId}`;
|
|
319
|
+
if (access.kind === "website")
|
|
320
|
+
return `this computer, for one website: ${named(access)}`;
|
|
321
|
+
return `this computer, for all websites in “${clean(access.name, 80)}” (including websites added later)`;
|
|
322
|
+
}
|
|
323
|
+
async function status(args, out, cwd) {
|
|
266
324
|
const { values } = parseArgs({ args, options: { json: { type: "boolean" } } });
|
|
267
325
|
const endpoint = endpointFrom();
|
|
268
|
-
const
|
|
269
|
-
const
|
|
270
|
-
|
|
326
|
+
const connection = await Connection.open(endpoint);
|
|
327
|
+
const credential = connection.access.kind === "token" ? null : load(endpoint);
|
|
328
|
+
let project = null;
|
|
329
|
+
let problem = null;
|
|
330
|
+
try {
|
|
331
|
+
project = await chooseWebsite(connection, cwd);
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
if (!choiceProblem(error))
|
|
335
|
+
throw error;
|
|
336
|
+
problem = error;
|
|
337
|
+
}
|
|
338
|
+
const info = project ? (await project.request("")).data : null;
|
|
339
|
+
const access = connection.access;
|
|
340
|
+
if (values.json) {
|
|
341
|
+
out.log(JSON.stringify({
|
|
342
|
+
endpoint,
|
|
343
|
+
sign_in: access.kind === "token" ? { kind: "token", project_id: access.projectId } : { kind: access.kind, id: access.id, name: access.name },
|
|
344
|
+
project: info,
|
|
345
|
+
chosen_by: project ? project.chosenBy : null,
|
|
346
|
+
problem: problem?.message ?? null,
|
|
347
|
+
scope: credential?.scope ?? null,
|
|
348
|
+
}, null, 2));
|
|
349
|
+
return problem && problem.code !== CHOOSE ? 1 : 0;
|
|
350
|
+
}
|
|
351
|
+
out.log(`Endpoint: ${endpoint}`);
|
|
352
|
+
out.log(`Signed in: ${describeAccess(connection)}`);
|
|
353
|
+
if (project && info) {
|
|
354
|
+
out.log(`This folder: ${named(info)}, ${describeChoice(project.chosenBy, cwd)}`);
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
out.log(`This folder: no website. ${problem.message}`);
|
|
358
|
+
}
|
|
359
|
+
if (credential?.scope)
|
|
360
|
+
out.log(`Allowed: ${permissions(credential.scope)}`);
|
|
361
|
+
if (info)
|
|
362
|
+
out.log(`Agent changes on ${named(info)} ${info.agent_approval ? "wait for a person's approval" : "apply right away"}.`);
|
|
363
|
+
return problem && problem.code !== CHOOSE ? 1 : 0;
|
|
364
|
+
}
|
|
365
|
+
async function websites(args, out, cwd) {
|
|
366
|
+
const { values } = parseArgs({ args, options: { json: { type: "boolean" } } });
|
|
367
|
+
const connection = await Connection.open();
|
|
368
|
+
const list = await connection.projects();
|
|
369
|
+
let current = null;
|
|
370
|
+
let problem = null;
|
|
371
|
+
try {
|
|
372
|
+
current = await chooseWebsite(connection, cwd);
|
|
373
|
+
}
|
|
374
|
+
catch (error) {
|
|
375
|
+
if (!choiceProblem(error))
|
|
376
|
+
throw error;
|
|
377
|
+
problem = error;
|
|
378
|
+
}
|
|
271
379
|
if (values.json) {
|
|
272
|
-
out.log(JSON.stringify({
|
|
380
|
+
out.log(JSON.stringify({ websites: list.map((p) => ({ ...p, this_folder: p.id === current?.projectId })), this_folder: current ? { id: current.projectId, chosen_by: current.chosenBy } : null }, null, 2));
|
|
273
381
|
return 0;
|
|
274
382
|
}
|
|
275
|
-
|
|
276
|
-
out.log(
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
383
|
+
const access = connection.access;
|
|
384
|
+
out.log(access.kind === "workspace"
|
|
385
|
+
? `Websites this sign-in reaches (all websites in “${clean(access.name, 80)}”):`
|
|
386
|
+
: access.kind === "token" ? "The website this token reaches:" : "This sign-in is for one website:");
|
|
387
|
+
if (!list.length)
|
|
388
|
+
out.log(" (none right now)");
|
|
389
|
+
const width = Math.max(...list.map((p) => String(p.id).length), 2);
|
|
390
|
+
for (const p of list) {
|
|
391
|
+
const mark = p.id === current?.projectId ? ` ← this folder (${describeChoice(current.chosenBy, cwd)})` : "";
|
|
392
|
+
out.log(` ${String(p.id).padStart(width)} ${clean(p.name, 60)}${p.url ? ` ${clean(p.url, 80)}` : ""}${mark}`);
|
|
393
|
+
}
|
|
394
|
+
if (!current && problem && list.length > 1)
|
|
395
|
+
out.log(`\nNo website chosen for this folder yet. Choose one: ${CLI} use <id or name>`);
|
|
396
|
+
else if (!current && problem)
|
|
397
|
+
out.log(`\n${problem.message}`);
|
|
280
398
|
return 0;
|
|
281
399
|
}
|
|
400
|
+
async function use(args, out, cwd) {
|
|
401
|
+
const { positionals } = parseArgs({ args, allowPositionals: true, options: {} });
|
|
402
|
+
const asked = positionals.join(" ").trim();
|
|
403
|
+
const connection = await Connection.open();
|
|
404
|
+
const list = await connection.projects();
|
|
405
|
+
let chosen;
|
|
406
|
+
if (asked) {
|
|
407
|
+
const found = matching(list, asked);
|
|
408
|
+
if (found.length > 1)
|
|
409
|
+
throw new CliError(`More than one website is called “${clean(asked, 80)}”: ${found.map((p) => p.id).join(", ")}. Use its id: ${CLI} use <id>.`, CHOOSE);
|
|
410
|
+
if (!found.length) {
|
|
411
|
+
const hint = connection.access.kind === "workspace"
|
|
412
|
+
? `${CLI} websites lists the ones this sign-in reaches.`
|
|
413
|
+
: `This sign-in is for ${list.map((p) => named(p)).join(", ") || "no website"} only: to reach others, run ${CLI} login and choose all websites in the workspace.`;
|
|
414
|
+
throw new CliError(`No website this sign-in reaches matches “${clean(asked, 80)}”. Use an id or the exact name. ${hint}`, CHOOSE);
|
|
415
|
+
}
|
|
416
|
+
chosen = found[0];
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
if (!list.length)
|
|
420
|
+
throw new CliError("This sign-in reaches no website right now.", "no_website");
|
|
421
|
+
chosen = await pick(list, out);
|
|
422
|
+
if (!chosen)
|
|
423
|
+
throw new CliError(`Say which website: ${CLI} use <id or name> (${CLI} websites lists them).`, CHOOSE);
|
|
424
|
+
}
|
|
425
|
+
const file = writeFolderChoice(cwd, chosen);
|
|
426
|
+
out.log(`This folder now uses ${named(chosen)}. Saved in ${FOLDER_FILE}: the choice is for this folder on this computer.`);
|
|
427
|
+
const git = gitPlace(file);
|
|
428
|
+
if (git.repo && !git.ignored)
|
|
429
|
+
out.log(`Git does not ignore .commentkit/ here yet: add .commentkit/ to .gitignore so the choice stays on this computer (${CLI} init does this).`);
|
|
430
|
+
if (process.env.COMMENTKIT_TOKEN)
|
|
431
|
+
out.log("COMMENTKIT_TOKEN is set in this terminal: while it is, COMMENTKIT_PROJECT_ID decides the website instead.");
|
|
432
|
+
return 0;
|
|
433
|
+
}
|
|
434
|
+
/** @internal The terminal a numbered choice is asked in; tests replace it. */
|
|
435
|
+
export const terminal = {
|
|
436
|
+
interactive: () => Boolean(process.stdin.isTTY),
|
|
437
|
+
async question(text) {
|
|
438
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
439
|
+
try {
|
|
440
|
+
return await rl.question(text);
|
|
441
|
+
}
|
|
442
|
+
finally {
|
|
443
|
+
rl.close();
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
};
|
|
447
|
+
/** A numbered choice in a terminal; undefined when there is no terminal or no valid answer. */
|
|
448
|
+
async function pick(list, out) {
|
|
449
|
+
if (!terminal.interactive())
|
|
450
|
+
return undefined;
|
|
451
|
+
if (list.length === 1)
|
|
452
|
+
return list[0];
|
|
453
|
+
out.log("Which website is this folder for?");
|
|
454
|
+
list.forEach((p, i) => out.log(` ${String(i + 1).padStart(2)}. ${clean(p.name, 60)}${p.url ? ` ${clean(p.url, 80)}` : ""} (id ${p.id})`));
|
|
455
|
+
const n = Number((await terminal.question(`Number (1-${list.length}): `)).trim());
|
|
456
|
+
return Number.isInteger(n) && n >= 1 && n <= list.length ? list[n - 1] : undefined;
|
|
457
|
+
}
|
|
282
458
|
async function ask(question, yes) {
|
|
283
459
|
if (yes)
|
|
284
460
|
return true;
|
|
@@ -304,12 +480,39 @@ async function init(args, out, cwd) {
|
|
|
304
480
|
const yes = Boolean(values.yes);
|
|
305
481
|
const dryRun = Boolean(values["dry-run"]);
|
|
306
482
|
let key = values.key;
|
|
483
|
+
// With a workspace sign-in, the website whose key init installs is remembered for this folder.
|
|
484
|
+
let remember = null;
|
|
307
485
|
if (!key) {
|
|
308
|
-
const
|
|
309
|
-
|
|
486
|
+
const connection = await Connection.open();
|
|
487
|
+
let project;
|
|
488
|
+
try {
|
|
489
|
+
project = await chooseWebsite(connection, cwd);
|
|
490
|
+
}
|
|
491
|
+
catch (error) {
|
|
492
|
+
// A workspace sign-in and nothing in the folder says which website yet: ask, in a terminal.
|
|
493
|
+
if (!(error instanceof CliError && error.code === CHOOSE))
|
|
494
|
+
throw error;
|
|
495
|
+
const chosen = await pick(await connection.projects(), out);
|
|
496
|
+
if (!chosen)
|
|
497
|
+
throw error;
|
|
498
|
+
project = new Project(connection, chosen.id, chosen.name);
|
|
499
|
+
}
|
|
500
|
+
const info = (await project.request("")).data;
|
|
501
|
+
key = info.publishable_keys.live ?? info.publishable_keys.test ?? undefined;
|
|
310
502
|
if (!key)
|
|
311
|
-
throw new CliError(
|
|
312
|
-
out.log(`Project: ${info.
|
|
503
|
+
throw new CliError(`This website has no publishable key yet. In CommentKit, open ${DASHBOARD.install} and press Create the key, then try again.`);
|
|
504
|
+
out.log(`Project: ${clean(info.name, 80)}`);
|
|
505
|
+
if (connection.access.kind === "workspace")
|
|
506
|
+
remember = info;
|
|
507
|
+
}
|
|
508
|
+
else if (PUBLISHABLE_KEY.test(key) && !process.env.COMMENTKIT_TOKEN && savedSignInKind() === "workspace") {
|
|
509
|
+
// --key with a saved workspace sign-in: remember the website the key belongs to, when it is one of them.
|
|
510
|
+
try {
|
|
511
|
+
remember = websiteWithKey(await (await Connection.open()).projects(), key) ?? null;
|
|
512
|
+
}
|
|
513
|
+
catch (error) {
|
|
514
|
+
out.log(`Could not check which website the key belongs to (${error instanceof Error ? error.message : String(error)}), so no website was saved for this folder.`);
|
|
515
|
+
}
|
|
313
516
|
}
|
|
314
517
|
if (!PUBLISHABLE_KEY.test(key))
|
|
315
518
|
throw new CliError("That is not a publishable key (pk_live_… or pk_test_…).");
|
|
@@ -321,7 +524,7 @@ async function init(args, out, cwd) {
|
|
|
321
524
|
if (after === before)
|
|
322
525
|
return;
|
|
323
526
|
if (dryRun) {
|
|
324
|
-
out.log(`Would ${
|
|
527
|
+
out.log(`Would ${existsSync(join(cwd, file)) ? "change" : "create"} ${file}:\n${addedLines(before, after)}\n`);
|
|
325
528
|
return;
|
|
326
529
|
}
|
|
327
530
|
if (await ask(question, yes)) {
|
|
@@ -332,17 +535,30 @@ async function init(args, out, cwd) {
|
|
|
332
535
|
skipped++;
|
|
333
536
|
};
|
|
334
537
|
const readOr = (file) => (existsSync(join(cwd, file)) ? readFileSync(join(cwd, file), "utf8") : "");
|
|
335
|
-
if (p.envVar) {
|
|
538
|
+
if (p.envVar && p.envFile) {
|
|
336
539
|
const before = readOr(p.envFile);
|
|
337
540
|
await change(p.envFile, before, setEnv(before, p.envVar, key), `Add ${p.envVar} to ${p.envFile}?`);
|
|
338
541
|
}
|
|
339
542
|
const ignoreBefore = readOr(".gitignore");
|
|
340
543
|
await change(".gitignore", ignoreBefore, ignoreFolder(ignoreBefore), "Add .commentkit/ to .gitignore (pulled feedback stays on your computer)?");
|
|
544
|
+
if (remember) {
|
|
545
|
+
let current = null;
|
|
546
|
+
try {
|
|
547
|
+
current = findFolderChoice(cwd);
|
|
548
|
+
}
|
|
549
|
+
catch {
|
|
550
|
+
// A damaged choice file is replaced below, after asking.
|
|
551
|
+
}
|
|
552
|
+
if (current?.projectId !== remember.id) {
|
|
553
|
+
await change(FOLDER_FILE, readOr(FOLDER_FILE), folderChoiceText(remember), `Remember ${named(remember)} as this folder's website in ${FOLDER_FILE} (for this folder on this computer)?`);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
const configBefore = p.configFile ? readOr(p.configFile) : "";
|
|
341
557
|
if (p.configFile && p.configEdit) {
|
|
342
|
-
await change(p.configFile,
|
|
558
|
+
await change(p.configFile, configBefore, p.configEdit, `Add the CommentKit build plugin to ${p.configFile}?`);
|
|
343
559
|
}
|
|
344
560
|
else if (p.configFile && !p.configEdit) {
|
|
345
|
-
out.log(`Could not edit ${p.configFile} safely, so it was left as it is. Add the build plugin by hand:\n ${p.configSnippet}\n(more: https://commentkit.dev/docs/frameworks)`);
|
|
561
|
+
out.log(`Could not edit ${p.configFile} safely, so it was left as it is. Add the build plugin by hand:\n ${p.configSnippet}\n${PLUGIN_NODE_NOTE}\n(more: https://commentkit.dev/docs/frameworks)\n`);
|
|
346
562
|
}
|
|
347
563
|
if (p.entry && p.entry !== "done") {
|
|
348
564
|
const { file, content, created } = p.entry;
|
|
@@ -350,6 +566,11 @@ async function init(args, out, cwd) {
|
|
|
350
566
|
}
|
|
351
567
|
for (const line of p.manual)
|
|
352
568
|
out.log(`By hand: ${line}`);
|
|
569
|
+
for (const line of p.notes)
|
|
570
|
+
out.log(line);
|
|
571
|
+
// Laravel servers often build on deploy, with whatever Node they have.
|
|
572
|
+
if (p.framework === "laravel" && p.configFile && p.configEdit && p.configEdit !== configBefore)
|
|
573
|
+
out.log(PLUGIN_NODE_NOTE);
|
|
353
574
|
if (p.install.length) {
|
|
354
575
|
if (values.install && !dryRun) {
|
|
355
576
|
for (const command of p.install) {
|
|
@@ -365,7 +586,7 @@ async function init(args, out, cwd) {
|
|
|
365
586
|
}
|
|
366
587
|
}
|
|
367
588
|
if (p.entry === "done")
|
|
368
|
-
out.log(
|
|
589
|
+
out.log(`\nThe widget is already in your app${p.widget ? ` (${describePlace(p.widget)})` : ""}.`);
|
|
369
590
|
else if (!p.entry)
|
|
370
591
|
out.log(`\nLast step, show the widget. ${p.snippet}\n`);
|
|
371
592
|
if (dryRun) {
|
|
@@ -377,6 +598,15 @@ async function init(args, out, cwd) {
|
|
|
377
598
|
out.log("Then start your dev server: the Comment button appears on localhost for your team.");
|
|
378
599
|
return 0;
|
|
379
600
|
}
|
|
601
|
+
/** What the saved sign-in is for, without the network; null when there is none or the file cannot be read. */
|
|
602
|
+
function savedSignInKind() {
|
|
603
|
+
try {
|
|
604
|
+
return signInTarget(load(endpointFrom()))?.kind ?? null;
|
|
605
|
+
}
|
|
606
|
+
catch {
|
|
607
|
+
return null;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
380
610
|
/** The lines `after` adds to `before`, marked with +, for a dry run. */
|
|
381
611
|
export function addedLines(before, after) {
|
|
382
612
|
const old = new Set(before.split("\n"));
|
|
@@ -410,8 +640,15 @@ async function mcp(args, out, cwd) {
|
|
|
410
640
|
out.log(NEXT_STEP[target]);
|
|
411
641
|
return 0;
|
|
412
642
|
}
|
|
643
|
+
// A project file that git ignores stays on this computer: each developer adds it for themselves.
|
|
644
|
+
const ignored = scope === "project" ? gitPlace(file) : null;
|
|
645
|
+
const ignoredNote = ignored?.ignored
|
|
646
|
+
? `Git ignores ${relative(cwd, file) || file}${ignored.rule ? ` (${ignored.rule})` : ""}, so this stays on this computer and is not shared through the repository: each developer who wants CommentKit in their agent runs npx @commentkit/comment-kit mcp install ${target} --scope project themselves.`
|
|
647
|
+
: null;
|
|
413
648
|
if (values["dry-run"]) {
|
|
414
649
|
out.log(`Would ${before === null ? "create" : merged.status === "replaced" ? "replace the commentkit entry in" : "add CommentKit to"} ${file}:\n${addedLines(before ?? "", merged.content)}`);
|
|
650
|
+
if (ignoredNote)
|
|
651
|
+
out.log(ignoredNote);
|
|
415
652
|
out.log("\nRun it again without --dry-run to write it.");
|
|
416
653
|
return 0;
|
|
417
654
|
}
|
|
@@ -421,7 +658,10 @@ async function mcp(args, out, cwd) {
|
|
|
421
658
|
}
|
|
422
659
|
const copy = before !== null ? backup(file) : null;
|
|
423
660
|
writeAtomic(file, merged.content);
|
|
424
|
-
|
|
661
|
+
const away = copy && dirname(copy) !== dirname(file) ? " (kept outside the repository, so git does not pick it up)" : "";
|
|
662
|
+
out.log(`${merged.status === "replaced" ? "Replaced" : "Added"} CommentKit (${url}) in ${file}.${copy ? ` Backup: ${copy}${away}` : ""}`);
|
|
663
|
+
if (ignoredNote)
|
|
664
|
+
out.log(ignoredNote);
|
|
425
665
|
out.log(NEXT_STEP[target]);
|
|
426
666
|
return 0;
|
|
427
667
|
}
|
|
@@ -441,7 +681,7 @@ async function runDoctor(args, out, cwd) {
|
|
|
441
681
|
const PULL_MAX = 500;
|
|
442
682
|
async function pull(args, out, cwd) {
|
|
443
683
|
const { values } = parseArgs({ args, options: { out: { type: "string" }, json: { type: "boolean" }, all: { type: "boolean" } } });
|
|
444
|
-
const project = await Project.connect();
|
|
684
|
+
const project = await Project.connect(undefined, undefined, undefined, cwd);
|
|
445
685
|
const info = await project.request("");
|
|
446
686
|
const threads = [];
|
|
447
687
|
let cursor;
|
|
@@ -461,11 +701,11 @@ async function pull(args, out, cwd) {
|
|
|
461
701
|
out.log(`Saved ${threads.length} item(s) to ${file}.${more ? ` There are more: only the ${PULL_MAX} with the latest activity were saved.` : ""}`);
|
|
462
702
|
return 0;
|
|
463
703
|
}
|
|
464
|
-
async function open(args, out) {
|
|
704
|
+
async function open(args, out, cwd) {
|
|
465
705
|
const ref = args[0];
|
|
466
706
|
if (ref && !/^(CK-)?\d{1,9}$/i.test(ref))
|
|
467
707
|
throw new CliError("Give a task reference like CK-12.");
|
|
468
|
-
const project = await Project.connect();
|
|
708
|
+
const project = await Project.connect(undefined, undefined, undefined, cwd);
|
|
469
709
|
const info = await project.request("");
|
|
470
710
|
let url = info.data.tasks_url;
|
|
471
711
|
if (ref) {
|
|
@@ -477,16 +717,17 @@ async function open(args, out) {
|
|
|
477
717
|
out.log("(Open the link above in your browser.)");
|
|
478
718
|
return 0;
|
|
479
719
|
}
|
|
480
|
-
async function token(args, out) {
|
|
720
|
+
async function token(args, out, cwd) {
|
|
481
721
|
const [sub, ...rest] = args;
|
|
482
|
-
|
|
722
|
+
// A CI token is always for one website: the one this folder uses.
|
|
723
|
+
const project = await Project.connect(undefined, undefined, undefined, cwd);
|
|
483
724
|
if (!sub || sub === "list") {
|
|
484
725
|
const { values } = parseArgs({ args: rest, options: { json: { type: "boolean" } } });
|
|
485
726
|
const list = await project.request("/tokens");
|
|
486
727
|
if (values.json)
|
|
487
728
|
out.log(JSON.stringify(list.data, null, 2));
|
|
488
729
|
else if (!list.data.length)
|
|
489
|
-
out.log(
|
|
730
|
+
out.log(`No agent tokens for ${named({ id: project.projectId, name: project.name })}.`);
|
|
490
731
|
else
|
|
491
732
|
for (const t of list.data)
|
|
492
733
|
out.log(`${String(t.id).padEnd(6)} ${t.name.padEnd(28)} ${["read", ...t.scopes].join(",").padEnd(18)} ${t.expires_at ? `expires ${t.expires_at.slice(0, 10)}` : ""}`);
|
|
@@ -503,7 +744,7 @@ async function token(args, out) {
|
|
|
503
744
|
method: "POST",
|
|
504
745
|
body: { name, scopes: [values.reply ? "reply" : null, values.status ? "status" : null].filter(Boolean), ...(values.days ? { days: Number(values.days) } : {}) },
|
|
505
746
|
});
|
|
506
|
-
out.log(`Created “${created.data.name}” (id ${created.data.id}). It is shown only once:\n\n${created.data.token}\n`);
|
|
747
|
+
out.log(`Created “${clean(created.data.name, 80)}” (id ${created.data.id}) for ${named({ id: project.projectId, name: project.name })}. It is shown only once:\n\n${created.data.token}\n`);
|
|
507
748
|
out.log(`In CI set COMMENTKIT_TOKEN to it and COMMENTKIT_PROJECT_ID=${project.projectId}.`);
|
|
508
749
|
return 0;
|
|
509
750
|
}
|