@sanity/cli-core 3.9.2 → 3.10.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.
@@ -39,6 +39,36 @@ interface Flow {
39
39
  }
40
40
  /** Create a {@link Flow} that writes rail lines through `log`. */
41
41
  declare function createFlow(log: LogFn): Flow;
42
+ type ChecklistRole = {
43
+ title: string;
44
+ value: string;
45
+ };
46
+ type ChecklistItem = {
47
+ checked?: boolean;
48
+ loadRoles?: () => Promise<ChecklistRole[]>;
49
+ name: string;
50
+ role?: string;
51
+ roles?: ChecklistRole[];
52
+ suffix?: string;
53
+ value: string;
54
+ };
55
+ type ChecklistAnswer = {
56
+ role?: string;
57
+ value: string;
58
+ };
59
+ type RoleChecklistConfig = {
60
+ message: string;
61
+ pageSize?: number;
62
+ sections: {
63
+ items: ChecklistItem[];
64
+ title: string;
65
+ }[];
66
+ };
67
+ type PromptContext = {
68
+ input?: NodeJS.ReadableStream;
69
+ output?: NodeJS.WritableStream;
70
+ };
71
+ declare const roleChecklist$1: (config: RoleChecklistConfig, context?: PromptContext) => Promise<ChecklistAnswer[]>;
42
72
  declare const checkbox: typeof inquirer.checkbox;
43
73
  declare const confirm: typeof inquirer.confirm;
44
74
  declare const editor: typeof inquirer.editor;
@@ -47,6 +77,7 @@ declare const input: typeof inquirer.input;
47
77
  declare const number: typeof inquirer.number;
48
78
  declare const password: typeof inquirer.password;
49
79
  declare const rawlist: typeof inquirer.rawlist;
80
+ declare const roleChecklist: typeof roleChecklist$1;
50
81
  declare const search: typeof inquirer.search;
51
82
  declare const select: typeof inquirer.select;
52
83
  declare function spinner(options?: Options | string): Ora;
@@ -55,5 +86,5 @@ type Spinner = Spinner$1;
55
86
  type SpinnerInstance = Ora;
56
87
  type SpinnerOptions = Options;
57
88
  type SpinnerPromiseOptions<T> = PromiseOptions<T>;
58
- export { type BoxenOptions, type Boxes, type CustomBorderStyle, type Flow, NonInteractiveError, Separator, type Spacing, type Spinner, type SpinnerInstance, type SpinnerOptions, type SpinnerPromiseOptions, boxen, checkbox, colorizeJson, confirm, createFlow, editor, expand, getTimer, input, logSymbols, number, password, rawlist, search, select, spinner, spinnerPromise };
89
+ export { type BoxenOptions, type Boxes, type ChecklistItem, type CustomBorderStyle, type Flow, NonInteractiveError, Separator, type Spacing, type Spinner, type SpinnerInstance, type SpinnerOptions, type SpinnerPromiseOptions, boxen, checkbox, colorizeJson, confirm, createFlow, editor, expand, getTimer, input, logSymbols, number, password, rawlist, roleChecklist, search, select, spinner, spinnerPromise };
59
90
  //# sourceMappingURL=ux.d.ts.map
@@ -3,7 +3,7 @@ export { boxen } from '../ux/boxen.js';
3
3
  export { colorizeJson } from '../ux/colorizeJson.js';
4
4
  export { createFlow } from '../ux/flowOutput.js';
5
5
  export { logSymbols } from '../ux/logSymbols.js';
6
- export { checkbox, confirm, editor, expand, input, number, password, rawlist, search, select, Separator } from '../ux/prompts.js';
6
+ export { checkbox, confirm, editor, expand, input, number, password, rawlist, roleChecklist, search, select, Separator } from '../ux/prompts.js';
7
7
  export { spinner, spinnerPromise } from '../ux/spinner.js';
8
8
  export { getTimer } from '../ux/timer.js';
9
9
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_exports/ux.ts"],"sourcesContent":["export {NonInteractiveError} from '../errors/NonInteractiveError.js'\nexport {\n boxen,\n type BoxenOptions,\n type Boxes,\n type CustomBorderStyle,\n type Spacing,\n} from '../ux/boxen.js'\nexport {colorizeJson} from '../ux/colorizeJson.js'\nexport {createFlow, type Flow} from '../ux/flowOutput.js'\nexport {logSymbols} from '../ux/logSymbols.js'\nexport {\n checkbox,\n confirm,\n editor,\n expand,\n input,\n number,\n password,\n rawlist,\n search,\n select,\n Separator,\n} from '../ux/prompts.js'\nexport {\n spinner,\n type Spinner,\n type SpinnerInstance,\n type SpinnerOptions,\n spinnerPromise,\n type SpinnerPromiseOptions,\n} from '../ux/spinner.js'\nexport {getTimer} from '../ux/timer.js'\n"],"names":["NonInteractiveError","boxen","colorizeJson","createFlow","logSymbols","checkbox","confirm","editor","expand","input","number","password","rawlist","search","select","Separator","spinner","spinnerPromise","getTimer"],"mappings":"AAAA,SAAQA,mBAAmB,QAAO,mCAAkC;AACpE,SACEC,KAAK,QAKA,iBAAgB;AACvB,SAAQC,YAAY,QAAO,wBAAuB;AAClD,SAAQC,UAAU,QAAkB,sBAAqB;AACzD,SAAQC,UAAU,QAAO,sBAAqB;AAC9C,SACEC,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,SAAS,QACJ,mBAAkB;AACzB,SACEC,OAAO,EAIPC,cAAc,QAET,mBAAkB;AACzB,SAAQC,QAAQ,QAAO,iBAAgB"}
1
+ {"version":3,"sources":["../../src/_exports/ux.ts"],"sourcesContent":["export {NonInteractiveError} from '../errors/NonInteractiveError.js'\nexport {\n boxen,\n type BoxenOptions,\n type Boxes,\n type CustomBorderStyle,\n type Spacing,\n} from '../ux/boxen.js'\nexport {colorizeJson} from '../ux/colorizeJson.js'\nexport {createFlow, type Flow} from '../ux/flowOutput.js'\nexport {logSymbols} from '../ux/logSymbols.js'\nexport {\n checkbox,\n confirm,\n editor,\n expand,\n input,\n number,\n password,\n rawlist,\n roleChecklist,\n search,\n select,\n Separator,\n} from '../ux/prompts.js'\nexport {type ChecklistItem} from '../ux/roleChecklist.js'\nexport {\n spinner,\n type Spinner,\n type SpinnerInstance,\n type SpinnerOptions,\n spinnerPromise,\n type SpinnerPromiseOptions,\n} from '../ux/spinner.js'\nexport {getTimer} from '../ux/timer.js'\n"],"names":["NonInteractiveError","boxen","colorizeJson","createFlow","logSymbols","checkbox","confirm","editor","expand","input","number","password","rawlist","roleChecklist","search","select","Separator","spinner","spinnerPromise","getTimer"],"mappings":"AAAA,SAAQA,mBAAmB,QAAO,mCAAkC;AACpE,SACEC,KAAK,QAKA,iBAAgB;AACvB,SAAQC,YAAY,QAAO,wBAAuB;AAClD,SAAQC,UAAU,QAAkB,sBAAqB;AACzD,SAAQC,UAAU,QAAO,sBAAqB;AAC9C,SACEC,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,QAAQ,EACRC,OAAO,EACPC,aAAa,EACbC,MAAM,EACNC,MAAM,EACNC,SAAS,QACJ,mBAAkB;AAEzB,SACEC,OAAO,EAIPC,cAAc,QAET,mBAAkB;AACzB,SAAQC,QAAQ,QAAO,iBAAgB"}
@@ -1,6 +1,7 @@
1
1
  import * as inquirer from '@inquirer/prompts';
2
2
  import { NonInteractiveError } from '../errors/NonInteractiveError.js';
3
3
  import { isInteractive } from '../util/isInteractive.js';
4
+ import { roleChecklist as roleChecklistPrompt } from './roleChecklist.js';
4
5
  export { Separator } from '@inquirer/prompts';
5
6
  function assertInteractive(promptName) {
6
7
  if (!isInteractive()) {
@@ -39,6 +40,10 @@ export const rawlist = (...args)=>{
39
40
  assertInteractive('rawlist');
40
41
  return inquirer.rawlist(...args);
41
42
  };
43
+ export const roleChecklist = (...args)=>{
44
+ assertInteractive('roleChecklist');
45
+ return roleChecklistPrompt(...args);
46
+ };
42
47
  export const search = (...args)=>{
43
48
  assertInteractive('search');
44
49
  return inquirer.search(...args);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ux/prompts.ts"],"sourcesContent":["import * as inquirer from '@inquirer/prompts'\n\nimport {NonInteractiveError} from '../errors/NonInteractiveError.js'\nimport {isInteractive} from '../util/isInteractive.js'\n\nexport {Separator} from '@inquirer/prompts'\n\nfunction assertInteractive(promptName: string): void {\n if (!isInteractive()) {\n throw new NonInteractiveError(promptName)\n }\n}\n\nexport const checkbox: typeof inquirer.checkbox = (...args) => {\n assertInteractive('checkbox')\n return inquirer.checkbox(...args)\n}\n\nexport const confirm: typeof inquirer.confirm = (...args) => {\n assertInteractive('confirm')\n return inquirer.confirm(...args)\n}\n\nexport const editor: typeof inquirer.editor = (...args) => {\n assertInteractive('editor')\n return inquirer.editor(...args)\n}\n\nexport const expand: typeof inquirer.expand = (...args) => {\n assertInteractive('expand')\n return inquirer.expand(...args)\n}\n\nexport const input: typeof inquirer.input = (...args) => {\n assertInteractive('input')\n return inquirer.input(...args)\n}\n\nexport const number: typeof inquirer.number = (...args) => {\n assertInteractive('number')\n return inquirer.number(...args)\n}\n\nexport const password: typeof inquirer.password = (...args) => {\n assertInteractive('password')\n return inquirer.password(...args)\n}\n\nexport const rawlist: typeof inquirer.rawlist = (...args) => {\n assertInteractive('rawlist')\n return inquirer.rawlist(...args)\n}\n\nexport const search: typeof inquirer.search = (...args) => {\n assertInteractive('search')\n return inquirer.search(...args)\n}\n\nexport const select: typeof inquirer.select = (...args) => {\n assertInteractive('select')\n return inquirer.select(...args)\n}\n"],"names":["inquirer","NonInteractiveError","isInteractive","Separator","assertInteractive","promptName","checkbox","args","confirm","editor","expand","input","number","password","rawlist","search","select"],"mappings":"AAAA,YAAYA,cAAc,oBAAmB;AAE7C,SAAQC,mBAAmB,QAAO,mCAAkC;AACpE,SAAQC,aAAa,QAAO,2BAA0B;AAEtD,SAAQC,SAAS,QAAO,oBAAmB;AAE3C,SAASC,kBAAkBC,UAAkB;IAC3C,IAAI,CAACH,iBAAiB;QACpB,MAAM,IAAID,oBAAoBI;IAChC;AACF;AAEA,OAAO,MAAMC,WAAqC,CAAC,GAAGC;IACpDH,kBAAkB;IAClB,OAAOJ,SAASM,QAAQ,IAAIC;AAC9B,EAAC;AAED,OAAO,MAAMC,UAAmC,CAAC,GAAGD;IAClDH,kBAAkB;IAClB,OAAOJ,SAASQ,OAAO,IAAID;AAC7B,EAAC;AAED,OAAO,MAAME,SAAiC,CAAC,GAAGF;IAChDH,kBAAkB;IAClB,OAAOJ,SAASS,MAAM,IAAIF;AAC5B,EAAC;AAED,OAAO,MAAMG,SAAiC,CAAC,GAAGH;IAChDH,kBAAkB;IAClB,OAAOJ,SAASU,MAAM,IAAIH;AAC5B,EAAC;AAED,OAAO,MAAMI,QAA+B,CAAC,GAAGJ;IAC9CH,kBAAkB;IAClB,OAAOJ,SAASW,KAAK,IAAIJ;AAC3B,EAAC;AAED,OAAO,MAAMK,SAAiC,CAAC,GAAGL;IAChDH,kBAAkB;IAClB,OAAOJ,SAASY,MAAM,IAAIL;AAC5B,EAAC;AAED,OAAO,MAAMM,WAAqC,CAAC,GAAGN;IACpDH,kBAAkB;IAClB,OAAOJ,SAASa,QAAQ,IAAIN;AAC9B,EAAC;AAED,OAAO,MAAMO,UAAmC,CAAC,GAAGP;IAClDH,kBAAkB;IAClB,OAAOJ,SAASc,OAAO,IAAIP;AAC7B,EAAC;AAED,OAAO,MAAMQ,SAAiC,CAAC,GAAGR;IAChDH,kBAAkB;IAClB,OAAOJ,SAASe,MAAM,IAAIR;AAC5B,EAAC;AAED,OAAO,MAAMS,SAAiC,CAAC,GAAGT;IAChDH,kBAAkB;IAClB,OAAOJ,SAASgB,MAAM,IAAIT;AAC5B,EAAC"}
1
+ {"version":3,"sources":["../../src/ux/prompts.ts"],"sourcesContent":["import * as inquirer from '@inquirer/prompts'\n\nimport {NonInteractiveError} from '../errors/NonInteractiveError.js'\nimport {isInteractive} from '../util/isInteractive.js'\nimport {roleChecklist as roleChecklistPrompt} from './roleChecklist.js'\n\nexport {Separator} from '@inquirer/prompts'\n\nfunction assertInteractive(promptName: string): void {\n if (!isInteractive()) {\n throw new NonInteractiveError(promptName)\n }\n}\n\nexport const checkbox: typeof inquirer.checkbox = (...args) => {\n assertInteractive('checkbox')\n return inquirer.checkbox(...args)\n}\n\nexport const confirm: typeof inquirer.confirm = (...args) => {\n assertInteractive('confirm')\n return inquirer.confirm(...args)\n}\n\nexport const editor: typeof inquirer.editor = (...args) => {\n assertInteractive('editor')\n return inquirer.editor(...args)\n}\n\nexport const expand: typeof inquirer.expand = (...args) => {\n assertInteractive('expand')\n return inquirer.expand(...args)\n}\n\nexport const input: typeof inquirer.input = (...args) => {\n assertInteractive('input')\n return inquirer.input(...args)\n}\n\nexport const number: typeof inquirer.number = (...args) => {\n assertInteractive('number')\n return inquirer.number(...args)\n}\n\nexport const password: typeof inquirer.password = (...args) => {\n assertInteractive('password')\n return inquirer.password(...args)\n}\n\nexport const rawlist: typeof inquirer.rawlist = (...args) => {\n assertInteractive('rawlist')\n return inquirer.rawlist(...args)\n}\n\nexport const roleChecklist: typeof roleChecklistPrompt = (...args) => {\n assertInteractive('roleChecklist')\n return roleChecklistPrompt(...args)\n}\n\nexport const search: typeof inquirer.search = (...args) => {\n assertInteractive('search')\n return inquirer.search(...args)\n}\n\nexport const select: typeof inquirer.select = (...args) => {\n assertInteractive('select')\n return inquirer.select(...args)\n}\n"],"names":["inquirer","NonInteractiveError","isInteractive","roleChecklist","roleChecklistPrompt","Separator","assertInteractive","promptName","checkbox","args","confirm","editor","expand","input","number","password","rawlist","search","select"],"mappings":"AAAA,YAAYA,cAAc,oBAAmB;AAE7C,SAAQC,mBAAmB,QAAO,mCAAkC;AACpE,SAAQC,aAAa,QAAO,2BAA0B;AACtD,SAAQC,iBAAiBC,mBAAmB,QAAO,qBAAoB;AAEvE,SAAQC,SAAS,QAAO,oBAAmB;AAE3C,SAASC,kBAAkBC,UAAkB;IAC3C,IAAI,CAACL,iBAAiB;QACpB,MAAM,IAAID,oBAAoBM;IAChC;AACF;AAEA,OAAO,MAAMC,WAAqC,CAAC,GAAGC;IACpDH,kBAAkB;IAClB,OAAON,SAASQ,QAAQ,IAAIC;AAC9B,EAAC;AAED,OAAO,MAAMC,UAAmC,CAAC,GAAGD;IAClDH,kBAAkB;IAClB,OAAON,SAASU,OAAO,IAAID;AAC7B,EAAC;AAED,OAAO,MAAME,SAAiC,CAAC,GAAGF;IAChDH,kBAAkB;IAClB,OAAON,SAASW,MAAM,IAAIF;AAC5B,EAAC;AAED,OAAO,MAAMG,SAAiC,CAAC,GAAGH;IAChDH,kBAAkB;IAClB,OAAON,SAASY,MAAM,IAAIH;AAC5B,EAAC;AAED,OAAO,MAAMI,QAA+B,CAAC,GAAGJ;IAC9CH,kBAAkB;IAClB,OAAON,SAASa,KAAK,IAAIJ;AAC3B,EAAC;AAED,OAAO,MAAMK,SAAiC,CAAC,GAAGL;IAChDH,kBAAkB;IAClB,OAAON,SAASc,MAAM,IAAIL;AAC5B,EAAC;AAED,OAAO,MAAMM,WAAqC,CAAC,GAAGN;IACpDH,kBAAkB;IAClB,OAAON,SAASe,QAAQ,IAAIN;AAC9B,EAAC;AAED,OAAO,MAAMO,UAAmC,CAAC,GAAGP;IAClDH,kBAAkB;IAClB,OAAON,SAASgB,OAAO,IAAIP;AAC7B,EAAC;AAED,OAAO,MAAMN,gBAA4C,CAAC,GAAGM;IAC3DH,kBAAkB;IAClB,OAAOF,uBAAuBK;AAChC,EAAC;AAED,OAAO,MAAMQ,SAAiC,CAAC,GAAGR;IAChDH,kBAAkB;IAClB,OAAON,SAASiB,MAAM,IAAIR;AAC5B,EAAC;AAED,OAAO,MAAMS,SAAiC,CAAC,GAAGT;IAChDH,kBAAkB;IAClB,OAAON,SAASkB,MAAM,IAAIT;AAC5B,EAAC"}
@@ -0,0 +1,220 @@
1
+ import { styleText } from 'node:util';
2
+ import { createPrompt, isDownKey, isEnterKey, isSpaceKey, isUpKey, makeTheme, useEffect, useKeypress, usePagination, usePrefix, useRef, useState } from '@inquirer/core';
3
+ import { getErrorMessage } from '../errors/getErrorMessage.js';
4
+ const ROW_PREFIX_WIDTH = 4;
5
+ const ROLE_GAP = 4;
6
+ const MIN_LABEL_WIDTH = 12;
7
+ function formatLabel({ name, suffix }) {
8
+ return suffix ? `${name} ${suffix}` : name;
9
+ }
10
+ function formatRoleCell(title) {
11
+ return `‹ ${title} ›`;
12
+ }
13
+ export function getLabelWidth(items, terminalWidth) {
14
+ const longestLabel = Math.max(0, ...items.map((item)=>formatLabel(item).length));
15
+ const longestRoleCell = Math.max(0, ...items.flatMap((item)=>(item.roles ?? []).map(({ title })=>formatRoleCell(title).length)));
16
+ const available = terminalWidth - ROW_PREFIX_WIDTH - ROLE_GAP - longestRoleCell;
17
+ return Math.max(Math.min(longestLabel, available), MIN_LABEL_WIDTH);
18
+ }
19
+ export function fitLabel(item, width) {
20
+ const label = formatLabel(item);
21
+ if (label.length <= width) return label.padEnd(width);
22
+ const suffix = item.suffix ? ` ${item.suffix}` : '';
23
+ const name = item.name.slice(0, Math.max(width - suffix.length - 1, 0)).trimEnd();
24
+ return `${name}…${suffix}`.padEnd(width);
25
+ }
26
+ function renderRow(row, isActive, labelWidth) {
27
+ const cursor = isActive ? '❯' : ' ';
28
+ const box = row.checked ? styleText('green', '◉') : '◯';
29
+ const roleTitle = row.roles?.find(({ value })=>value === row.role)?.title ?? row.role;
30
+ const roleCell = roleTitle ? formatRoleCell(roleTitle) : '';
31
+ const line = `${cursor} ${box} ${fitLabel(row, labelWidth)}${' '.repeat(ROLE_GAP)}${row.checked ? roleCell : styleText('dim', roleCell)}`.trimEnd();
32
+ return isActive ? styleText('cyan', line) : line;
33
+ }
34
+ function cycleRole(row, offset) {
35
+ const roles = row.roles ?? [];
36
+ const index = roles.findIndex(({ value })=>value === row.role);
37
+ const next = roles[(index + offset + roles.length) % roles.length];
38
+ return next ? {
39
+ ...row,
40
+ role: next.value
41
+ } : row;
42
+ }
43
+ function findSubmitError(rows, isLoading) {
44
+ const selected = rows.filter((row)=>row.checked);
45
+ if (selected.length === 0) return 'Select at least one option';
46
+ const loading = selected.find((row)=>isLoading(row));
47
+ if (loading) return `Still loading roles for ${loading.name}. Press ⏎ again in a moment`;
48
+ const unloaded = selected.find((row)=>row.loadRoles);
49
+ if (unloaded) return `Couldn't load roles for ${unloaded.name}. Press ←→ to retry, or uncheck it`;
50
+ const roleless = selected.find((row)=>row.roles?.length === 0);
51
+ if (roleless) return `${roleless.name} has no roles that tokens can use. Uncheck it to continue`;
52
+ return undefined;
53
+ }
54
+ function renderHelp() {
55
+ return [
56
+ [
57
+ '↑↓',
58
+ 'navigate'
59
+ ],
60
+ [
61
+ 'space',
62
+ 'toggle'
63
+ ],
64
+ [
65
+ '←→',
66
+ 'role'
67
+ ],
68
+ [
69
+ 'type',
70
+ 'to filter'
71
+ ],
72
+ [
73
+ '⏎',
74
+ 'submit'
75
+ ]
76
+ ].map(([key, action])=>`${styleText('bold', key)} ${styleText('dim', action)}`).join(styleText('dim', ' • '));
77
+ }
78
+ export const roleChecklist = createPrompt((config, done)=>{
79
+ const { message, pageSize = 15 } = config;
80
+ const theme = makeTheme({});
81
+ const [status, setStatus] = useState('idle');
82
+ const prefix = usePrefix({
83
+ status,
84
+ theme
85
+ });
86
+ const [rows, setRows] = useState(()=>config.sections.flatMap(({ items, title })=>items.map((item)=>({
87
+ ...item,
88
+ checked: item.checked ?? false,
89
+ section: title
90
+ }))));
91
+ const [filter, setFilter] = useState('');
92
+ const [active, setActive] = useState(0);
93
+ const [error, setError] = useState();
94
+ const pendingLoads = useRef(new Map());
95
+ const settled = useRef(false);
96
+ const query = filter.toLowerCase();
97
+ const visible = rows.filter((row)=>formatLabel(row).toLowerCase().includes(query));
98
+ const current = visible[active];
99
+ const updateRow = (value, update)=>setRows((all)=>all.map((row)=>row.value === value ? update(row) : row));
100
+ const fetchRoles = async (value, load)=>{
101
+ try {
102
+ const roles = await load();
103
+ if (settled.current) return;
104
+ updateRow(value, (row)=>({
105
+ ...row,
106
+ loadRoles: undefined,
107
+ role: roles.some((role)=>role.value === row.role) ? row.role : roles[0]?.value,
108
+ roles
109
+ }));
110
+ } catch (err) {
111
+ if (!settled.current) setError(getErrorMessage(err));
112
+ } finally{
113
+ pendingLoads.current.delete(value);
114
+ }
115
+ };
116
+ const loadRoles = (row)=>{
117
+ if (!row.loadRoles) return Promise.resolve();
118
+ const pending = pendingLoads.current.get(row.value) ?? fetchRoles(row.value, row.loadRoles);
119
+ pendingLoads.current.set(row.value, pending);
120
+ return pending;
121
+ };
122
+ useEffect(()=>{
123
+ for (const row of rows.filter(({ checked })=>checked)){
124
+ void loadRoles(row);
125
+ }
126
+ }, []);
127
+ useKeypress(async (key, rl)=>{
128
+ if (isEnterKey(key)) {
129
+ const submitError = findSubmitError(rows, (row)=>pendingLoads.current.has(row.value));
130
+ if (submitError) {
131
+ setError(submitError);
132
+ return;
133
+ }
134
+ settled.current = true;
135
+ setStatus('done');
136
+ done(rows.filter((row)=>row.checked).map(({ role, value })=>({
137
+ role,
138
+ value
139
+ })));
140
+ return;
141
+ }
142
+ setError(undefined);
143
+ if (isUpKey(key) || isDownKey(key)) {
144
+ const next = active + (isUpKey(key) ? -1 : 1);
145
+ setActive(Math.max(Math.min(next, visible.length - 1), 0));
146
+ return;
147
+ }
148
+ const isRoleKey = key.name === 'left' || key.name === 'right';
149
+ if (!isSpaceKey(key) && !isRoleKey) {
150
+ setFilter(rl.line);
151
+ setActive(0);
152
+ return;
153
+ }
154
+ // readline has already applied the space or arrow to its line buffer, so restore the filter
155
+ rl.clearLine(0);
156
+ rl.write(filter);
157
+ if (!current) return;
158
+ if (isSpaceKey(key)) {
159
+ const checked = !current.checked;
160
+ updateRow(current.value, (row)=>({
161
+ ...row,
162
+ checked
163
+ }));
164
+ if (checked) await loadRoles(current);
165
+ return;
166
+ }
167
+ const offset = key.name === 'right' ? 1 : -1;
168
+ if (current.loadRoles) {
169
+ await loadRoles(current);
170
+ if (settled.current) return;
171
+ }
172
+ updateRow(current.value, (row)=>cycleRole(row, offset));
173
+ });
174
+ const labelWidth = getLabelWidth(rows, process.stdout.columns || 80);
175
+ const entries = visible.flatMap((row, index)=>{
176
+ if (row.section === visible[index - 1]?.section) return [
177
+ row
178
+ ];
179
+ const header = styleText('bold', ` ${row.section}`);
180
+ return [
181
+ index === 0 ? header : `\n${header}`,
182
+ row
183
+ ];
184
+ });
185
+ const page = usePagination({
186
+ active: current ? entries.indexOf(current) : 0,
187
+ items: entries.length > 0 ? entries : [
188
+ styleText('dim', ' No matches')
189
+ ],
190
+ loop: false,
191
+ pageSize,
192
+ renderItem: ({ isActive, item })=>typeof item === 'string' ? item : renderRow(item, isActive, labelWidth)
193
+ });
194
+ const header = [
195
+ prefix,
196
+ theme.style.message(message, status)
197
+ ];
198
+ if (status === 'done') {
199
+ const answer = rows.filter((row)=>row.checked).map(({ name })=>name);
200
+ return [
201
+ ...header,
202
+ theme.style.answer(answer.join(', '))
203
+ ].join(' ');
204
+ }
205
+ const body = [
206
+ page,
207
+ ' ',
208
+ error ? theme.style.error(error) : '',
209
+ renderHelp()
210
+ ];
211
+ return [
212
+ [
213
+ ...header,
214
+ filter
215
+ ].join(' '),
216
+ body.filter(Boolean).join('\n')
217
+ ];
218
+ });
219
+
220
+ //# sourceMappingURL=roleChecklist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ux/roleChecklist.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {\n createPrompt,\n isDownKey,\n isEnterKey,\n isSpaceKey,\n isUpKey,\n makeTheme,\n useEffect,\n useKeypress,\n usePagination,\n usePrefix,\n useRef,\n useState,\n} from '@inquirer/core'\n\nimport {getErrorMessage} from '../errors/getErrorMessage.js'\n\ntype ChecklistRole = {title: string; value: string}\n\nexport type ChecklistItem = {\n checked?: boolean\n loadRoles?: () => Promise<ChecklistRole[]>\n name: string\n role?: string\n roles?: ChecklistRole[]\n suffix?: string\n value: string\n}\n\ntype ChecklistAnswer = {role?: string; value: string}\n\ntype RoleChecklistConfig = {\n message: string\n pageSize?: number\n sections: {items: ChecklistItem[]; title: string}[]\n}\n\ntype Row = ChecklistItem & {\n checked: boolean\n section: string\n}\n\ntype PromptContext = {\n input?: NodeJS.ReadableStream\n output?: NodeJS.WritableStream\n}\n\nconst ROW_PREFIX_WIDTH = 4\nconst ROLE_GAP = 4\nconst MIN_LABEL_WIDTH = 12\n\nfunction formatLabel({name, suffix}: ChecklistItem): string {\n return suffix ? `${name} ${suffix}` : name\n}\n\nfunction formatRoleCell(title: string): string {\n return `‹ ${title} ›`\n}\n\nexport function getLabelWidth(items: ChecklistItem[], terminalWidth: number): number {\n const longestLabel = Math.max(0, ...items.map((item) => formatLabel(item).length))\n const longestRoleCell = Math.max(\n 0,\n ...items.flatMap((item) => (item.roles ?? []).map(({title}) => formatRoleCell(title).length)),\n )\n const available = terminalWidth - ROW_PREFIX_WIDTH - ROLE_GAP - longestRoleCell\n return Math.max(Math.min(longestLabel, available), MIN_LABEL_WIDTH)\n}\n\nexport function fitLabel(item: ChecklistItem, width: number): string {\n const label = formatLabel(item)\n if (label.length <= width) return label.padEnd(width)\n\n const suffix = item.suffix ? ` ${item.suffix}` : ''\n const name = item.name.slice(0, Math.max(width - suffix.length - 1, 0)).trimEnd()\n return `${name}…${suffix}`.padEnd(width)\n}\n\nfunction renderRow(row: Row, isActive: boolean, labelWidth: number): string {\n const cursor = isActive ? '❯' : ' '\n const box = row.checked ? styleText('green', '◉') : '◯'\n const roleTitle = row.roles?.find(({value}) => value === row.role)?.title ?? row.role\n const roleCell = roleTitle ? formatRoleCell(roleTitle) : ''\n const line = `${cursor} ${box} ${fitLabel(row, labelWidth)}${' '.repeat(ROLE_GAP)}${\n row.checked ? roleCell : styleText('dim', roleCell)\n }`.trimEnd()\n return isActive ? styleText('cyan', line) : line\n}\n\nfunction cycleRole(row: Row, offset: number): Row {\n const roles = row.roles ?? []\n const index = roles.findIndex(({value}) => value === row.role)\n const next = roles[(index + offset + roles.length) % roles.length]\n return next ? {...row, role: next.value} : row\n}\n\nfunction findSubmitError(rows: Row[], isLoading: (row: Row) => boolean): string | undefined {\n const selected = rows.filter((row) => row.checked)\n if (selected.length === 0) return 'Select at least one option'\n\n const loading = selected.find((row) => isLoading(row))\n if (loading) return `Still loading roles for ${loading.name}. Press ⏎ again in a moment`\n\n const unloaded = selected.find((row) => row.loadRoles)\n if (unloaded) return `Couldn't load roles for ${unloaded.name}. Press ←→ to retry, or uncheck it`\n\n const roleless = selected.find((row) => row.roles?.length === 0)\n if (roleless) return `${roleless.name} has no roles that tokens can use. Uncheck it to continue`\n\n return undefined\n}\n\nfunction renderHelp(): string {\n return [\n ['↑↓', 'navigate'],\n ['space', 'toggle'],\n ['←→', 'role'],\n ['type', 'to filter'],\n ['⏎', 'submit'],\n ]\n .map(([key, action]) => `${styleText('bold', key)} ${styleText('dim', action)}`)\n .join(styleText('dim', ' • '))\n}\n\nexport const roleChecklist: (\n config: RoleChecklistConfig,\n context?: PromptContext,\n) => Promise<ChecklistAnswer[]> = createPrompt<ChecklistAnswer[], RoleChecklistConfig>(\n (config, done) => {\n const {message, pageSize = 15} = config\n const theme = makeTheme({})\n const [status, setStatus] = useState<'done' | 'idle'>('idle')\n const prefix = usePrefix({status, theme})\n const [rows, setRows] = useState<Row[]>(() =>\n config.sections.flatMap(({items, title}) =>\n items.map((item) => ({\n ...item,\n checked: item.checked ?? false,\n section: title,\n })),\n ),\n )\n const [filter, setFilter] = useState('')\n const [active, setActive] = useState(0)\n const [error, setError] = useState<string>()\n const pendingLoads = useRef(new Map<string, Promise<void>>())\n const settled = useRef(false)\n\n const query = filter.toLowerCase()\n const visible = rows.filter((row) => formatLabel(row).toLowerCase().includes(query))\n const current = visible[active]\n\n const updateRow = (value: string, update: (row: Row) => Row) =>\n setRows((all) => all.map((row) => (row.value === value ? update(row) : row)))\n\n const fetchRoles = async (value: string, load: () => Promise<ChecklistRole[]>) => {\n try {\n const roles = await load()\n if (settled.current) return\n updateRow(value, (row) => ({\n ...row,\n loadRoles: undefined,\n role: roles.some((role) => role.value === row.role) ? row.role : roles[0]?.value,\n roles,\n }))\n } catch (err) {\n if (!settled.current) setError(getErrorMessage(err))\n } finally {\n pendingLoads.current.delete(value)\n }\n }\n\n const loadRoles = (row: Row): Promise<void> => {\n if (!row.loadRoles) return Promise.resolve()\n\n const pending = pendingLoads.current.get(row.value) ?? fetchRoles(row.value, row.loadRoles)\n pendingLoads.current.set(row.value, pending)\n return pending\n }\n\n useEffect(() => {\n for (const row of rows.filter(({checked}) => checked)) {\n void loadRoles(row)\n }\n }, [])\n\n useKeypress(async (key, rl) => {\n if (isEnterKey(key)) {\n const submitError = findSubmitError(rows, (row) => pendingLoads.current.has(row.value))\n if (submitError) {\n setError(submitError)\n return\n }\n settled.current = true\n setStatus('done')\n done(rows.filter((row) => row.checked).map(({role, value}) => ({role, value})))\n return\n }\n\n setError(undefined)\n\n if (isUpKey(key) || isDownKey(key)) {\n const next = active + (isUpKey(key) ? -1 : 1)\n setActive(Math.max(Math.min(next, visible.length - 1), 0))\n return\n }\n\n const isRoleKey = key.name === 'left' || key.name === 'right'\n if (!isSpaceKey(key) && !isRoleKey) {\n setFilter(rl.line)\n setActive(0)\n return\n }\n\n // readline has already applied the space or arrow to its line buffer, so restore the filter\n rl.clearLine(0)\n rl.write(filter)\n if (!current) return\n\n if (isSpaceKey(key)) {\n const checked = !current.checked\n updateRow(current.value, (row) => ({...row, checked}))\n if (checked) await loadRoles(current)\n return\n }\n\n const offset = key.name === 'right' ? 1 : -1\n if (current.loadRoles) {\n await loadRoles(current)\n if (settled.current) return\n }\n updateRow(current.value, (row) => cycleRole(row, offset))\n })\n\n const labelWidth = getLabelWidth(rows, process.stdout.columns || 80)\n const entries: (Row | string)[] = visible.flatMap((row, index) => {\n if (row.section === visible[index - 1]?.section) return [row]\n const header = styleText('bold', ` ${row.section}`)\n return [index === 0 ? header : `\\n${header}`, row]\n })\n const page = usePagination({\n active: current ? entries.indexOf(current) : 0,\n items: entries.length > 0 ? entries : [styleText('dim', ' No matches')],\n loop: false,\n pageSize,\n renderItem: ({isActive, item}) =>\n typeof item === 'string' ? item : renderRow(item, isActive, labelWidth),\n })\n\n const header = [prefix, theme.style.message(message, status)]\n if (status === 'done') {\n const answer = rows.filter((row) => row.checked).map(({name}) => name)\n return [...header, theme.style.answer(answer.join(', '))].join(' ')\n }\n\n const body = [page, ' ', error ? theme.style.error(error) : '', renderHelp()]\n return [[...header, filter].join(' '), body.filter(Boolean).join('\\n')]\n },\n)\n"],"names":["styleText","createPrompt","isDownKey","isEnterKey","isSpaceKey","isUpKey","makeTheme","useEffect","useKeypress","usePagination","usePrefix","useRef","useState","getErrorMessage","ROW_PREFIX_WIDTH","ROLE_GAP","MIN_LABEL_WIDTH","formatLabel","name","suffix","formatRoleCell","title","getLabelWidth","items","terminalWidth","longestLabel","Math","max","map","item","length","longestRoleCell","flatMap","roles","available","min","fitLabel","width","label","padEnd","slice","trimEnd","renderRow","row","isActive","labelWidth","cursor","box","checked","roleTitle","find","value","role","roleCell","line","repeat","cycleRole","offset","index","findIndex","next","findSubmitError","rows","isLoading","selected","filter","loading","unloaded","loadRoles","roleless","undefined","renderHelp","key","action","join","roleChecklist","config","done","message","pageSize","theme","status","setStatus","prefix","setRows","sections","section","setFilter","active","setActive","error","setError","pendingLoads","Map","settled","query","toLowerCase","visible","includes","current","updateRow","update","all","fetchRoles","load","some","err","delete","Promise","resolve","pending","get","set","rl","submitError","has","isRoleKey","clearLine","write","process","stdout","columns","entries","header","page","indexOf","loop","renderItem","style","answer","body","Boolean"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SACEC,YAAY,EACZC,SAAS,EACTC,UAAU,EACVC,UAAU,EACVC,OAAO,EACPC,SAAS,EACTC,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,iBAAgB;AAEvB,SAAQC,eAAe,QAAO,+BAA8B;AAgC5D,MAAMC,mBAAmB;AACzB,MAAMC,WAAW;AACjB,MAAMC,kBAAkB;AAExB,SAASC,YAAY,EAACC,IAAI,EAAEC,MAAM,EAAgB;IAChD,OAAOA,SAAS,GAAGD,KAAK,CAAC,EAAEC,QAAQ,GAAGD;AACxC;AAEA,SAASE,eAAeC,KAAa;IACnC,OAAO,CAAC,EAAE,EAAEA,MAAM,EAAE,CAAC;AACvB;AAEA,OAAO,SAASC,cAAcC,KAAsB,EAAEC,aAAqB;IACzE,MAAMC,eAAeC,KAAKC,GAAG,CAAC,MAAMJ,MAAMK,GAAG,CAAC,CAACC,OAASZ,YAAYY,MAAMC,MAAM;IAChF,MAAMC,kBAAkBL,KAAKC,GAAG,CAC9B,M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2C,IAAI2C,OAAO,EAAE;QACnD,OAAO;YAAC5B,UAAU,IAAIiE,SAAS,CAAC,EAAE,EAAEA,QAAQ;YAAEhF;SAAI;IACpD;IACA,MAAMiF,OAAOnH,cAAc;QACzB+E,QAAQW,UAAUuB,QAAQG,OAAO,CAAC1B,WAAW;QAC7C5E,OAAOmG,QAAQ5F,MAAM,GAAG,IAAI4F,UAAU;YAAC1H,UAAU,OAAO;SAAgB;QACxE8H,MAAM;QACN/C;QACAgD,YAAY,CAAC,EAACnF,QAAQ,EAAEf,IAAI,EAAC,GAC3B,OAAOA,SAAS,WAAWA,OAAOa,UAAUb,MAAMe,UAAUC;IAChE;IAEA,MAAM8E,SAAS;QAACxC;QAAQH,MAAMgD,KAAK,CAAClD,OAAO,CAACA,SAASG;KAAQ;IAC7D,IAAIA,WAAW,QAAQ;QACrB,MAAMgD,SAASnE,KAAKG,MAAM,CAAC,CAACtB,MAAQA,IAAIK,OAAO,EAAEpB,GAAG,CAAC,CAAC,EAACV,IAAI,EAAC,GAAKA;QACjE,OAAO;eAAIyG;YAAQ3C,MAAMgD,KAAK,CAACC,MAAM,CAACA,OAAOvD,IAAI,CAAC;SAAO,CAACA,IAAI,CAAC;IACjE;IAEA,MAAMwD,OAAO;QAACN;QAAM;QAAKlC,QAAQV,MAAMgD,KAAK,CAACtC,KAAK,CAACA,SAAS;QAAInB;KAAa;IAC7E,OAAO;QAAC;eAAIoD;YAAQ1D;SAAO,CAACS,IAAI,CAAC;QAAMwD,KAAKjE,MAAM,CAACkE,SAASzD,IAAI,CAAC;KAAM;AACzE,GACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli-core",
3
- "version": "3.9.2",
3
+ "version": "3.10.0",
4
4
  "description": "Sanity CLI core package",
5
5
  "keywords": [
6
6
  "cli",
@@ -119,6 +119,7 @@
119
119
  "access": "public"
120
120
  },
121
121
  "dependencies": {
122
+ "@inquirer/core": "^12.0.3",
122
123
  "@inquirer/prompts": "^8.5.2",
123
124
  "@oclif/core": "^4.11.14",
124
125
  "@sanity/client": "^8.9.0",