@sanity/cli-core 3.9.1 → 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.
- package/dist/_exports/ux.d.ts +32 -1
- package/dist/_exports/ux.js +1 -1
- package/dist/_exports/ux.js.map +1 -1
- package/dist/config/studio/getStudioWorkspaces.js +5 -6
- package/dist/config/studio/getStudioWorkspaces.js.map +1 -1
- package/dist/ux/prompts.js +5 -0
- package/dist/ux/prompts.js.map +1 -1
- package/dist/ux/roleChecklist.js +220 -0
- package/dist/ux/roleChecklist.js.map +1 -0
- package/package.json +2 -1
package/dist/_exports/ux.d.ts
CHANGED
|
@@ -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
|
package/dist/_exports/ux.js
CHANGED
|
@@ -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
|
|
package/dist/_exports/ux.js.map
CHANGED
|
@@ -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;
|
|
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"}
|
|
@@ -24,14 +24,13 @@ const debug = subdebug('worker:getStudioWorkspaces');
|
|
|
24
24
|
configPath = await findStudioConfigPath(configPath);
|
|
25
25
|
}
|
|
26
26
|
debug('Finding studio config path %s', configPath);
|
|
27
|
-
|
|
27
|
+
const mod = await doImport(configPath);
|
|
28
|
+
// Named exports like `projectId` can make the module itself look like a config
|
|
29
|
+
const config = 'default' in mod && isStudioConfig(mod.default) ? mod.default : mod;
|
|
28
30
|
debug('Imported config %o', config);
|
|
29
31
|
if (!isStudioConfig(config)) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
throw new TypeError(`Invalid studio config format in "${configPath}"`);
|
|
33
|
-
}
|
|
34
|
-
config = config.default;
|
|
32
|
+
debug('Invalid studio config format in "%s"', configPath);
|
|
33
|
+
throw new TypeError(`Invalid studio config format in "${configPath}"`);
|
|
35
34
|
}
|
|
36
35
|
const workDir = dirname(configPath);
|
|
37
36
|
debug('Work dir %s', workDir);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/config/studio/getStudioWorkspaces.ts"],"sourcesContent":["import {stat} from 'node:fs/promises'\nimport {dirname} from 'node:path'\nimport {isMainThread} from 'node:worker_threads'\n\nimport {type Workspace} from 'sanity'\n\nimport {subdebug} from '../../_exports/debug.js'\nimport {doImport} from '../../util/doImport.js'\nimport {resolveLocalPackage} from '../../util/resolveLocalPackage.js'\nimport {findStudioConfigPath} from '../util/findStudioConfigPath.js'\nimport {isStudioConfig} from './isStudioConfig.js'\n\nconst debug = subdebug('worker:getStudioWorkspaces')\n\n/**\n * Resolves the workspaces from the studio config.\n *\n * NOTE: This function should only be called from a worker thread.\n *\n * @param configPath - The path to the studio config\n * @returns The workspaces\n * @internal\n */\nexport async function getStudioWorkspaces(configPath: string): Promise<Workspace[]> {\n if (isMainThread) {\n throw new Error('getStudioWorkspaces should only be called from a worker thread')\n }\n const isDirectory = (await stat(configPath)).isDirectory()\n if (isDirectory) {\n configPath = await findStudioConfigPath(configPath)\n }\n debug('Finding studio config path %s', configPath)\n
|
|
1
|
+
{"version":3,"sources":["../../../src/config/studio/getStudioWorkspaces.ts"],"sourcesContent":["import {stat} from 'node:fs/promises'\nimport {dirname} from 'node:path'\nimport {isMainThread} from 'node:worker_threads'\n\nimport {type Workspace} from 'sanity'\n\nimport {subdebug} from '../../_exports/debug.js'\nimport {doImport} from '../../util/doImport.js'\nimport {resolveLocalPackage} from '../../util/resolveLocalPackage.js'\nimport {findStudioConfigPath} from '../util/findStudioConfigPath.js'\nimport {isStudioConfig} from './isStudioConfig.js'\n\nconst debug = subdebug('worker:getStudioWorkspaces')\n\n/**\n * Resolves the workspaces from the studio config.\n *\n * NOTE: This function should only be called from a worker thread.\n *\n * @param configPath - The path to the studio config\n * @returns The workspaces\n * @internal\n */\nexport async function getStudioWorkspaces(configPath: string): Promise<Workspace[]> {\n if (isMainThread) {\n throw new Error('getStudioWorkspaces should only be called from a worker thread')\n }\n const isDirectory = (await stat(configPath)).isDirectory()\n if (isDirectory) {\n configPath = await findStudioConfigPath(configPath)\n }\n debug('Finding studio config path %s', configPath)\n const mod = await doImport(configPath)\n // Named exports like `projectId` can make the module itself look like a config\n const config = 'default' in mod && isStudioConfig(mod.default) ? mod.default : mod\n\n debug('Imported config %o', config)\n if (!isStudioConfig(config)) {\n debug('Invalid studio config format in \"%s\"', configPath)\n throw new TypeError(`Invalid studio config format in \"${configPath}\"`)\n }\n\n const workDir = dirname(configPath)\n debug('Work dir %s', workDir)\n const {resolveConfig} = await resolveLocalPackage<typeof import('sanity')>('sanity', workDir)\n if (typeof resolveConfig !== 'function') {\n throw new TypeError('Expected `resolveConfig` from `sanity` to be a function')\n }\n\n // We will also want to stub out some configuration - we don't need to resolve the\n // users' logged in state, for instance - so let's disable the auth implementation.\n const rawWorkspaces = Array.isArray(config)\n ? config\n : [{...config, basePath: config.basePath || '/', name: config.name || 'default'}]\n\n // Imported lazily: rxjs and `@sanity/client` are only needed here, but this\n // module is reachable from the `@sanity/cli-core` barrel that every command loads.\n const [{firstValueFrom, of}, {getEmptyAuth}] = await Promise.all([\n // eslint-disable-next-line no-restricted-syntax -- package import, not a file path\n import('rxjs'),\n // eslint-disable-next-line no-restricted-syntax -- static relative import, not a user file path\n import('../../util/getEmptyAuth.js'),\n ])\n const emptyAuth = {state: of(getEmptyAuth())}\n\n const unauthedWorkspaces = rawWorkspaces.map((workspace) => ({\n ...workspace,\n auth: emptyAuth,\n }))\n\n debug('Unauthed workspaces %o', unauthedWorkspaces)\n\n return firstValueFrom(resolveConfig(unauthedWorkspaces))\n}\n"],"names":["stat","dirname","isMainThread","subdebug","doImport","resolveLocalPackage","findStudioConfigPath","isStudioConfig","debug","getStudioWorkspaces","configPath","Error","isDirectory","mod","config","default","TypeError","workDir","resolveConfig","rawWorkspaces","Array","isArray","basePath","name","firstValueFrom","of","getEmptyAuth","Promise","all","emptyAuth","state","unauthedWorkspaces","map","workspace","auth"],"mappings":"AAAA,SAAQA,IAAI,QAAO,mBAAkB;AACrC,SAAQC,OAAO,QAAO,YAAW;AACjC,SAAQC,YAAY,QAAO,sBAAqB;AAIhD,SAAQC,QAAQ,QAAO,0BAAyB;AAChD,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,oBAAoB,QAAO,kCAAiC;AACpE,SAAQC,cAAc,QAAO,sBAAqB;AAElD,MAAMC,QAAQL,SAAS;AAEvB;;;;;;;;CAQC,GACD,OAAO,eAAeM,oBAAoBC,UAAkB;IAC1D,IAAIR,cAAc;QAChB,MAAM,IAAIS,MAAM;IAClB;IACA,MAAMC,cAAc,AAAC,CAAA,MAAMZ,KAAKU,WAAU,EAAGE,WAAW;IACxD,IAAIA,aAAa;QACfF,aAAa,MAAMJ,qBAAqBI;IAC1C;IACAF,MAAM,iCAAiCE;IACvC,MAAMG,MAAM,MAAMT,SAASM;IAC3B,+EAA+E;IAC/E,MAAMI,SAAS,aAAaD,OAAON,eAAeM,IAAIE,OAAO,IAAIF,IAAIE,OAAO,GAAGF;IAE/EL,MAAM,sBAAsBM;IAC5B,IAAI,CAACP,eAAeO,SAAS;QAC3BN,MAAM,wCAAwCE;QAC9C,MAAM,IAAIM,UAAU,CAAC,iCAAiC,EAAEN,WAAW,CAAC,CAAC;IACvE;IAEA,MAAMO,UAAUhB,QAAQS;IACxBF,MAAM,eAAeS;IACrB,MAAM,EAACC,aAAa,EAAC,GAAG,MAAMb,oBAA6C,UAAUY;IACrF,IAAI,OAAOC,kBAAkB,YAAY;QACvC,MAAM,IAAIF,UAAU;IACtB;IAEA,kFAAkF;IAClF,mFAAmF;IACnF,MAAMG,gBAAgBC,MAAMC,OAAO,CAACP,UAChCA,SACA;QAAC;YAAC,GAAGA,MAAM;YAAEQ,UAAUR,OAAOQ,QAAQ,IAAI;YAAKC,MAAMT,OAAOS,IAAI,IAAI;QAAS;KAAE;IAEnF,4EAA4E;IAC5E,mFAAmF;IACnF,MAAM,CAAC,EAACC,cAAc,EAAEC,EAAE,EAAC,EAAE,EAACC,YAAY,EAAC,CAAC,GAAG,MAAMC,QAAQC,GAAG,CAAC;QAC/D,mFAAmF;QACnF,MAAM,CAAC;QACP,gGAAgG;QAChG,MAAM,CAAC;KACR;IACD,MAAMC,YAAY;QAACC,OAAOL,GAAGC;IAAe;IAE5C,MAAMK,qBAAqBZ,cAAca,GAAG,CAAC,CAACC,YAAe,CAAA;YAC3D,GAAGA,SAAS;YACZC,MAAML;QACR,CAAA;IAEArB,MAAM,0BAA0BuB;IAEhC,OAAOP,eAAeN,cAAca;AACtC"}
|
package/dist/ux/prompts.js
CHANGED
|
@@ -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);
|
package/dist/ux/prompts.js.map
CHANGED
|
@@ -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;
|
|
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,MACGJ,MAAMS,OAAO,CAAC,CAACH,OAAS,AAACA,CAAAA,KAAKI,KAAK,IAAI,EAAE,AAAD,EAAGL,GAAG,CAAC,CAAC,EAACP,KAAK,EAAC,GAAKD,eAAeC,OAAOS,MAAM;IAE7F,MAA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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.
|
|
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",
|