@shopify/cli-kit 4.9.5 โ 5.0.1
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/cli/api/graphql/admin/generated/metafield_definitions_by_owner_type.d.ts +5 -0
- package/dist/cli/api/graphql/admin/generated/metafield_definitions_by_owner_type.js +22 -0
- package/dist/cli/api/graphql/admin/generated/metafield_definitions_by_owner_type.js.map +1 -1
- package/dist/private/node/api/graphql.d.ts +2 -1
- package/dist/private/node/api/graphql.js +12 -1
- package/dist/private/node/api/graphql.js.map +1 -1
- package/dist/private/node/api.d.ts +2 -0
- package/dist/private/node/api.js +49 -22
- package/dist/private/node/api.js.map +1 -1
- package/dist/private/node/command-json-schema.js +1 -0
- package/dist/private/node/command-json-schema.js.map +1 -1
- package/dist/private/node/constants.d.ts +1 -0
- package/dist/private/node/constants.js +1 -0
- package/dist/private/node/constants.js.map +1 -1
- package/dist/private/node/dev-instance-output.d.ts +47 -0
- package/dist/private/node/dev-instance-output.js +143 -0
- package/dist/private/node/dev-instance-output.js.map +1 -0
- package/dist/private/node/json-error.d.ts +1 -15
- package/dist/private/node/json-error.js +4 -98
- package/dist/private/node/json-error.js.map +1 -1
- package/dist/private/node/output-context.d.ts +8 -0
- package/dist/private/node/output-context.js +10 -0
- package/dist/private/node/output-context.js.map +1 -0
- package/dist/private/node/output.test.js +4 -4
- package/dist/private/node/output.test.js.map +1 -1
- package/dist/private/node/session/automation-token.d.ts +50 -0
- package/dist/private/node/session/automation-token.js +77 -0
- package/dist/private/node/session/automation-token.js.map +1 -0
- package/dist/private/node/session/exchange.d.ts +5 -1
- package/dist/private/node/session/exchange.js +97 -7
- package/dist/private/node/session/exchange.js.map +1 -1
- package/dist/private/node/session/permanent-store-domain.d.ts +21 -0
- package/dist/private/node/session/permanent-store-domain.js +72 -0
- package/dist/private/node/session/permanent-store-domain.js.map +1 -0
- package/dist/private/node/session.d.ts +3 -2
- package/dist/private/node/session.js +12 -3
- package/dist/private/node/session.js.map +1 -1
- package/dist/private/node/themes/trust-challenge.d.ts +31 -0
- package/dist/private/node/themes/trust-challenge.js +143 -0
- package/dist/private/node/themes/trust-challenge.js.map +1 -0
- package/dist/private/node/ui/alert.js +1 -1
- package/dist/private/node/ui/alert.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.d.ts +2 -7
- package/dist/private/node/ui/components/ConcurrentOutput.js +4 -8
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
- package/dist/private/node/ui/components/LoadingBar.js +9 -15
- package/dist/private/node/ui/components/LoadingBar.js.map +1 -1
- package/dist/private/node/ui/components/LoadingBar.test.js +45 -107
- package/dist/private/node/ui/components/LoadingBar.test.js.map +1 -1
- package/dist/private/node/ui/components/LoadingIndicator.d.ts +7 -0
- package/dist/private/node/ui/components/LoadingIndicator.js +22 -0
- package/dist/private/node/ui/components/LoadingIndicator.js.map +1 -0
- package/dist/private/node/ui/components/Table/Table.d.ts +8 -0
- package/dist/private/node/ui/components/Table/Table.js +18 -2
- package/dist/private/node/ui/components/Table/Table.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/api/admin.js +13 -0
- package/dist/public/node/api/admin.js.map +1 -1
- package/dist/public/node/api/graphql.js +38 -7
- package/dist/public/node/api/graphql.js.map +1 -1
- package/dist/public/node/archiver.js +13 -6
- package/dist/public/node/archiver.js.map +1 -1
- package/dist/public/node/base-command.d.ts +6 -0
- package/dist/public/node/base-command.js +97 -16
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/dev-instance.d.ts +138 -0
- package/dist/public/node/dev-instance.js +365 -0
- package/dist/public/node/dev-instance.js.map +1 -0
- package/dist/public/node/environment.d.ts +6 -3
- package/dist/public/node/environment.js +11 -4
- package/dist/public/node/environment.js.map +1 -1
- package/dist/public/node/error/index.js +2 -1
- package/dist/public/node/error/index.js.map +1 -1
- package/dist/public/node/error/schema.d.ts +24 -24
- package/dist/public/node/error/serialization.d.ts +8 -0
- package/dist/public/node/error/serialization.js +103 -0
- package/dist/public/node/error/serialization.js.map +1 -0
- package/dist/public/node/graphiql/server.js +18 -2
- package/dist/public/node/graphiql/server.js.map +1 -1
- package/dist/public/node/is-global.js +2 -1
- package/dist/public/node/is-global.js.map +1 -1
- package/dist/public/node/notifications-system.d.ts +6 -6
- package/dist/public/node/path.d.ts +19 -3
- package/dist/public/node/path.js +21 -3
- package/dist/public/node/path.js.map +1 -1
- package/dist/public/node/session.d.ts +38 -3
- package/dist/public/node/session.js +56 -9
- package/dist/public/node/session.js.map +1 -1
- package/dist/public/node/system.d.ts +4 -0
- package/dist/public/node/system.js +39 -9
- package/dist/public/node/system.js.map +1 -1
- package/dist/public/node/themes/api.d.ts +9 -0
- package/dist/public/node/themes/api.js +50 -22
- package/dist/public/node/themes/api.js.map +1 -1
- package/dist/public/node/themes/theme-manager.d.ts +8 -1
- package/dist/public/node/themes/theme-manager.js +1 -1
- package/dist/public/node/themes/theme-manager.js.map +1 -1
- package/dist/public/node/tree-kill.js +12 -2
- package/dist/public/node/tree-kill.js.map +1 -1
- package/dist/public/node/ui/components.d.ts +1 -0
- package/dist/public/node/ui/components.js +1 -0
- package/dist/public/node/ui/components.js.map +1 -1
- package/dist/public/node/ui.d.ts +24 -4
- package/dist/public/node/ui.js +54 -21
- package/dist/public/node/ui.js.map +1 -1
- package/dist/public/node/upgrade/output.d.ts +17 -0
- package/dist/public/node/upgrade/output.js +51 -0
- package/dist/public/node/upgrade/output.js.map +1 -0
- package/dist/public/node/upgrade/result.d.ts +8 -0
- package/dist/public/node/upgrade/result.js +21 -0
- package/dist/public/node/upgrade/result.js.map +1 -0
- package/dist/public/node/upgrade/types.d.ts +61 -0
- package/dist/public/node/upgrade/types.js +46 -0
- package/dist/public/node/upgrade/types.js.map +1 -0
- package/dist/public/node/upgrade.d.ts +8 -0
- package/dist/public/node/upgrade.js +57 -22
- package/dist/public/node/upgrade.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/private/node/ui/components/TextAnimation.d.ts +0 -10
- package/dist/private/node/ui/components/TextAnimation.js +0 -56
- package/dist/private/node/ui/components/TextAnimation.js.map +0 -1
- package/dist/private/node/ui/components/TextAnimation.test.d.ts +0 -1
- package/dist/private/node/ui/components/TextAnimation.test.js +0 -73
- package/dist/private/node/ui/components/TextAnimation.test.js.map +0 -1
|
@@ -11,5 +11,12 @@ export declare abstract class ThemeManager {
|
|
|
11
11
|
findOrCreate(name?: string, role?: Role): Promise<Theme>;
|
|
12
12
|
fetch(name?: string, role?: Role): Promise<Theme | undefined>;
|
|
13
13
|
generateThemeName(context: string): string;
|
|
14
|
-
create(themeRole?: Role, themeName?: string): Promise<
|
|
14
|
+
create(themeRole?: Role, themeName?: string): Promise<{
|
|
15
|
+
createdAtRuntime: boolean;
|
|
16
|
+
id: number;
|
|
17
|
+
name: string;
|
|
18
|
+
processing: boolean;
|
|
19
|
+
role: string;
|
|
20
|
+
src?: string;
|
|
21
|
+
}>;
|
|
15
22
|
}
|
|
@@ -44,7 +44,7 @@ export class ThemeManager {
|
|
|
44
44
|
throw new BugError(`Could not create theme with name "${name}" and role "${role}"`);
|
|
45
45
|
}
|
|
46
46
|
this.setTheme(theme.id.toString());
|
|
47
|
-
return theme;
|
|
47
|
+
return { ...theme, createdAtRuntime: true };
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
//# sourceMappingURL=theme-manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-manager.js","sourceRoot":"","sources":["../../../../src/public/node/themes/theme-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,0BAA0B,EAAE,WAAW,EAAC,MAAM,UAAU,CAAA;AAE5E,OAAO,EAAC,sBAAsB,EAAO,MAAM,YAAY,CAAA;AACvD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qDAAqD,CAAA;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eCreate} from './api.js'\nimport {Theme} from './types.js'\nimport {DEVELOPMENT_THEME_ROLE, Role} from './utils.js'\nimport {generateThemeName} from '../../../private/node/themes/generate-theme-name.js'\nimport {AdminSession} from '../session.js'\nimport {BugError} from '../error.js'\n\nexport abstract class ThemeManager {\n protected themeId: string | undefined\n protected abstract setTheme(themeId: string): void\n protected abstract removeTheme(): void\n protected abstract context: string\n\n constructor(protected adminSession: AdminSession) {}\n\n async findOrCreate(name?: string, role?: Role): Promise<Theme> {\n let theme = await this.fetch(name, role)\n if (theme) {\n this.setTheme(theme.id.toString())\n } else {\n theme = await this.create(role, name)\n }\n return theme\n }\n\n async fetch(name?: string, role?: Role) {\n if (!this.themeId && !name) {\n return\n }\n\n const theme =\n name && role === DEVELOPMENT_THEME_ROLE\n ? await findDevelopmentThemeByName(name, this.adminSession)\n : await fetchTheme(parseInt(this.themeId!, 10), this.adminSession)\n\n if (!theme) {\n this.removeTheme()\n }\n return theme\n }\n\n generateThemeName(context: string) {\n return generateThemeName(context)\n }\n\n async create(themeRole?: Role, themeName?: string) {\n const name = themeName ?? generateThemeName(this.context)\n const role = themeRole ?? DEVELOPMENT_THEME_ROLE\n const theme = await themeCreate(\n {\n name,\n role,\n },\n this.adminSession,\n )\n if (!theme) {\n throw new BugError(`Could not create theme with name \"${name}\" and role \"${role}\"`)\n }\n this.setTheme(theme.id.toString())\n return {...theme, createdAtRuntime: true}\n }\n}\n"]}
|
|
@@ -49,13 +49,23 @@ function adaptedTreeKill(pid, killSignal, killRoot, callback) {
|
|
|
49
49
|
switch (process.platform) {
|
|
50
50
|
case 'win32': {
|
|
51
51
|
// Security: Use spawn instead of exec to avoid shell injection when killing processes on Windows
|
|
52
|
-
|
|
52
|
+
// Exclude the querying PowerShell process as well as the root when only children should stop.
|
|
53
|
+
const command = killRoot ? 'taskkill' : 'powershell.exe';
|
|
54
|
+
const args = killRoot
|
|
55
|
+
? ['/pid', rootPid, '/T', '/F']
|
|
56
|
+
: [
|
|
57
|
+
'-NoProfile',
|
|
58
|
+
'-NonInteractive',
|
|
59
|
+
'-Command',
|
|
60
|
+
`Get-CimInstance Win32_Process -Filter "ParentProcessId = ${rootPid} AND ProcessId <> $PID" -ErrorAction Stop | ForEach-Object { taskkill /pid $_.ProcessId /T /F | Out-Null }`,
|
|
61
|
+
];
|
|
62
|
+
const taskkill = spawn(command, args);
|
|
53
63
|
taskkill.on('close', (code) => {
|
|
54
64
|
if (code === 0) {
|
|
55
65
|
callback();
|
|
56
66
|
}
|
|
57
67
|
else {
|
|
58
|
-
callback(new Error(
|
|
68
|
+
callback(new Error(`${command} exited with code ${code}`));
|
|
59
69
|
}
|
|
60
70
|
});
|
|
61
71
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-kill.js","sourceRoot":"","sources":["../../../src/public/node/tree-kill.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,yCAAyC;AACzC,0CAA0C;AAE1C,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAA;AACvC,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAA;AAMnC;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CACtB,MAAuB,OAAO,CAAC,GAAG,EAClC,UAAU,GAAG,SAAS,EACtB,QAAQ,GAAG,IAAI,EACf,QAA4B;IAE5B,MAAM,KAAK,GACT,QAAQ;QACR,CAAC,CAAC,KAAa,EAAE,EAAE;YACjB,IAAI,KAAK;gBAAE,WAAW,CAAC,0BAA0B,GAAG,KAAK,KAAK,EAAE,CAAC,CAAA;QACnE,CAAC,CAAC,CAAA;IACJ,eAAe,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;AACnD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAS,eAAe,CACtB,GAAoB,EACpB,UAAkB,EAClB,QAAiB,EACjB,QAAiC;IAEjC,MAAM,OAAO,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CA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AAK,CAAC,CAAC,CAAE,CAAA;gBACrB,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAE,CAAA;gBACrB,IAAI,CAAC,SAAS,CAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBAC1B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;gBACd,WAAW,CAAC,mBAAmB,GAAG,KAAK,GAAG,EAAE,CAAC,CAAA;gBAC7C,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;gBACtB,gBAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,aAAa,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAA;YACzE,CAAC;QACH,CAAC,CAAC,CAAA;IACN,CAAC,CAAA;IAED,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n/* eslint-disable jsdoc/require-throws */\n/* eslint-disable no-restricted-imports */\n\nimport {outputDebug} from './output.js'\nimport {spawn} from 'child_process'\n\ntype ProcessTree = Record<string, string[]>\n\ntype AfterKillCallback = (error?: Error) => void\n\n/**\n * Kills the process that calls the method and all its children.\n *\n * @param pid - Pid of the process to kill.\n * @param killSignal - Type of kill signal to be used.\n * @param killRoot - Whether to kill the root process.\n * @param callback - Optional callback to run after killing the processes.\n */\nexport function treeKill(\n pid: number | string = process.pid,\n killSignal = 'SIGTERM',\n killRoot = true,\n callback?: AfterKillCallback,\n): void {\n const after =\n callback ??\n ((error?: Error) => {\n if (error) outputDebug(`Failed to kill process ${pid}: ${error}`)\n })\n adaptedTreeKill(pid, killSignal, killRoot, after)\n}\n\n/**\n * Adapted from https://github.com/pkrumins/node-tree-kill.\n *\n * Our implementation allows to skip killing the root process. This is useful for example when\n * gracefully exiting the 'dev' process, as the default tree-kill implementation will cause it\n * to exit with a non-zero code. Instead, we want to treat it as a graceful termination.\n * In addition, we also add debug logging for better visibility in what tree-kill is doing.\n *\n * @param pid - Pid of the process to kill.\n * @param killSignal - Type of kill signal to be used.\n * @param killRoot - Whether to kill the root process.\n * @param callback - Optional callback to run after killing the processes.\n */\nfunction adaptedTreeKill(\n pid: number | string,\n killSignal: string,\n killRoot: boolean,\n callback: (error?: Error) => void,\n): void {\n const rootPid = typeof pid === 'number' ? pid.toString() : pid\n\n // Security: Validate that the PID is a number to prevent command injection\n if (!/^\\d+$/.test(rootPid)) {\n callback(new Error('pid must be a number'))\n return\n }\n\n // A map from parent pid to an array of children pids\n const tree: ProcessTree = {}\n tree[rootPid] = []\n\n // A set of pids to visit. We use it to recursively find all the children pids\n const pidsToProcess = new Set<string>()\n pidsToProcess.add(rootPid)\n\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- default handles all Unix-like platforms\n switch (process.platform) {\n case 'win32': {\n // Security: Use spawn instead of exec to avoid shell injection when killing processes on Windows\n const taskkill = spawn('taskkill', ['/pid', rootPid, '/T', '/F'])\n taskkill.on('close', (code: number) => {\n if (code === 0) {\n callback()\n } else {\n callback(new Error(`taskkill exited with code ${code}`))\n }\n })\n break\n }\n case 'darwin':\n buildProcessTree(\n rootPid,\n tree,\n pidsToProcess,\n function (parentPid: string) {\n return spawn('pgrep', ['-lfP', parentPid])\n },\n function () {\n killAll(tree, killSignal, rootPid, killRoot, callback)\n },\n )\n break\n default:\n buildProcessTree(\n rootPid,\n tree,\n pidsToProcess,\n function (parentPid: string) {\n return spawn('ps', ['-o', 'pid command', '--no-headers', '--ppid', parentPid])\n },\n function () {\n killAll(tree, killSignal, rootPid, killRoot, callback)\n },\n )\n break\n }\n}\n\n/**\n * Kills all processes in the process tree.\n *\n * @param tree - Process tree.\n * @param killSignal - Type of kill signal to be used.\n * @param rootPid - Pid of the root process.\n * @param killRoot - Whether to kill the root process.\n * @param callback - Optional callback to run after killing the processes.\n */\nfunction killAll(\n tree: ProcessTree,\n killSignal: string,\n rootPid: string,\n killRoot: boolean,\n callback: AfterKillCallback,\n): void {\n const killed = new Set<string>()\n try {\n Object.keys(tree).forEach(function (pid) {\n tree[pid]!.forEach(function (pidpid) {\n if (!killed.has(pidpid)) {\n killPid(pidpid, killSignal)\n killed.add(pidpid)\n }\n })\n if (pid === rootPid && killRoot && !killed.has(pid)) {\n killPid(pid, killSignal)\n killed.add(pid)\n }\n })\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (err: unknown) {\n // @ts-ignore\n callback(err)\n return\n }\n callback()\n}\n\n/**\n * Kills a process.\n *\n * @param pid - Pid of the process to kill.\n * @param killSignal - Type of kill signal to be used.\n */\nfunction killPid(pid: string, killSignal: string) {\n try {\n process.kill(parseInt(pid, 10), killSignal)\n } catch (err) {\n // @ts-ignore\n if (err.code !== 'ESRCH') throw err\n }\n}\n\n/**\n * Builds a process tree.\n *\n * @param parentPid - Pid of the parent process.\n * @param tree - Process tree.\n * @param pidsToProcess - Pids to process.\n * @param spawnChildProcessesList - Function to spawn child processes.\n * @param cb - Callback to run after building the process tree.\n */\nfunction buildProcessTree(\n parentPid: string,\n tree: ProcessTree,\n pidsToProcess: Set<string>,\n spawnChildProcessesList: (parentPid: string) => ReturnType<typeof spawn>,\n cb: () => void,\n) {\n const ps = spawnChildProcessesList(parentPid)\n let allData = ''\n ps.stdout?.on('data', function (data: Buffer) {\n const dataStr = data.toString('ascii')\n allData += dataStr\n })\n\n const onClose = (code: number) => {\n pidsToProcess.delete(parentPid)\n\n if (code !== 0) {\n // no more parent processes\n if (pidsToProcess.size === 0) {\n cb()\n return\n }\n return\n }\n\n allData\n .trim()\n .split('\\n')\n .forEach(function (line) {\n const match = line.match(/^(\\d+)\\s(.*)$/)\n if (match) {\n const pid = match[1]!\n const cmd = match[2]!\n tree[parentPid]!.push(pid)\n tree[pid] = []\n outputDebug(`Killing process ${pid}: ${cmd}`)\n pidsToProcess.add(pid)\n buildProcessTree(pid, tree, pidsToProcess, spawnChildProcessesList, cb)\n }\n })\n }\n\n ps.on('close', onClose)\n}\n"]}
|
|
1
|
+
{"version":3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CAAA;gBACd,WAAW,CAAC,mBAAmB,GAAG,KAAK,GAAG,EAAE,CAAC,CAAA;gBAC7C,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;gBACtB,gBAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,aAAa,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAA;YACzE,CAAC;QACH,CAAC,CAAC,CAAA;IACN,CAAC,CAAA;IAED,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n/* eslint-disable jsdoc/require-throws */\n/* eslint-disable no-restricted-imports */\n\nimport {outputDebug} from './output.js'\nimport {spawn} from 'child_process'\n\ntype ProcessTree = Record<string, string[]>\n\ntype AfterKillCallback = (error?: Error) => void\n\n/**\n * Kills the process that calls the method and all its children.\n *\n * @param pid - Pid of the process to kill.\n * @param killSignal - Type of kill signal to be used.\n * @param killRoot - Whether to kill the root process.\n * @param callback - Optional callback to run after killing the processes.\n */\nexport function treeKill(\n pid: number | string = process.pid,\n killSignal = 'SIGTERM',\n killRoot = true,\n callback?: AfterKillCallback,\n): void {\n const after =\n callback ??\n ((error?: Error) => {\n if (error) outputDebug(`Failed to kill process ${pid}: ${error}`)\n })\n adaptedTreeKill(pid, killSignal, killRoot, after)\n}\n\n/**\n * Adapted from https://github.com/pkrumins/node-tree-kill.\n *\n * Our implementation allows to skip killing the root process. This is useful for example when\n * gracefully exiting the 'dev' process, as the default tree-kill implementation will cause it\n * to exit with a non-zero code. Instead, we want to treat it as a graceful termination.\n * In addition, we also add debug logging for better visibility in what tree-kill is doing.\n *\n * @param pid - Pid of the process to kill.\n * @param killSignal - Type of kill signal to be used.\n * @param killRoot - Whether to kill the root process.\n * @param callback - Optional callback to run after killing the processes.\n */\nfunction adaptedTreeKill(\n pid: number | string,\n killSignal: string,\n killRoot: boolean,\n callback: (error?: Error) => void,\n): void {\n const rootPid = typeof pid === 'number' ? pid.toString() : pid\n\n // Security: Validate that the PID is a number to prevent command injection\n if (!/^\\d+$/.test(rootPid)) {\n callback(new Error('pid must be a number'))\n return\n }\n\n // A map from parent pid to an array of children pids\n const tree: ProcessTree = {}\n tree[rootPid] = []\n\n // A set of pids to visit. We use it to recursively find all the children pids\n const pidsToProcess = new Set<string>()\n pidsToProcess.add(rootPid)\n\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- default handles all Unix-like platforms\n switch (process.platform) {\n case 'win32': {\n // Security: Use spawn instead of exec to avoid shell injection when killing processes on Windows\n // Exclude the querying PowerShell process as well as the root when only children should stop.\n const command = killRoot ? 'taskkill' : 'powershell.exe'\n const args = killRoot\n ? ['/pid', rootPid, '/T', '/F']\n : [\n '-NoProfile',\n '-NonInteractive',\n '-Command',\n `Get-CimInstance Win32_Process -Filter \"ParentProcessId = ${rootPid} AND ProcessId <> $PID\" -ErrorAction Stop | ForEach-Object { taskkill /pid $_.ProcessId /T /F | Out-Null }`,\n ]\n const taskkill = spawn(command, args)\n taskkill.on('close', (code: number) => {\n if (code === 0) {\n callback()\n } else {\n callback(new Error(`${command} exited with code ${code}`))\n }\n })\n break\n }\n case 'darwin':\n buildProcessTree(\n rootPid,\n tree,\n pidsToProcess,\n function (parentPid: string) {\n return spawn('pgrep', ['-lfP', parentPid])\n },\n function () {\n killAll(tree, killSignal, rootPid, killRoot, callback)\n },\n )\n break\n default:\n buildProcessTree(\n rootPid,\n tree,\n pidsToProcess,\n function (parentPid: string) {\n return spawn('ps', ['-o', 'pid command', '--no-headers', '--ppid', parentPid])\n },\n function () {\n killAll(tree, killSignal, rootPid, killRoot, callback)\n },\n )\n break\n }\n}\n\n/**\n * Kills all processes in the process tree.\n *\n * @param tree - Process tree.\n * @param killSignal - Type of kill signal to be used.\n * @param rootPid - Pid of the root process.\n * @param killRoot - Whether to kill the root process.\n * @param callback - Optional callback to run after killing the processes.\n */\nfunction killAll(\n tree: ProcessTree,\n killSignal: string,\n rootPid: string,\n killRoot: boolean,\n callback: AfterKillCallback,\n): void {\n const killed = new Set<string>()\n try {\n Object.keys(tree).forEach(function (pid) {\n tree[pid]!.forEach(function (pidpid) {\n if (!killed.has(pidpid)) {\n killPid(pidpid, killSignal)\n killed.add(pidpid)\n }\n })\n if (pid === rootPid && killRoot && !killed.has(pid)) {\n killPid(pid, killSignal)\n killed.add(pid)\n }\n })\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (err: unknown) {\n // @ts-ignore\n callback(err)\n return\n }\n callback()\n}\n\n/**\n * Kills a process.\n *\n * @param pid - Pid of the process to kill.\n * @param killSignal - Type of kill signal to be used.\n */\nfunction killPid(pid: string, killSignal: string) {\n try {\n process.kill(parseInt(pid, 10), killSignal)\n } catch (err) {\n // @ts-ignore\n if (err.code !== 'ESRCH') throw err\n }\n}\n\n/**\n * Builds a process tree.\n *\n * @param parentPid - Pid of the parent process.\n * @param tree - Process tree.\n * @param pidsToProcess - Pids to process.\n * @param spawnChildProcessesList - Function to spawn child processes.\n * @param cb - Callback to run after building the process tree.\n */\nfunction buildProcessTree(\n parentPid: string,\n tree: ProcessTree,\n pidsToProcess: Set<string>,\n spawnChildProcessesList: (parentPid: string) => ReturnType<typeof spawn>,\n cb: () => void,\n) {\n const ps = spawnChildProcessesList(parentPid)\n let allData = ''\n ps.stdout?.on('data', function (data: Buffer) {\n const dataStr = data.toString('ascii')\n allData += dataStr\n })\n\n const onClose = (code: number) => {\n pidsToProcess.delete(parentPid)\n\n if (code !== 0) {\n // no more parent processes\n if (pidsToProcess.size === 0) {\n cb()\n return\n }\n return\n }\n\n allData\n .trim()\n .split('\\n')\n .forEach(function (line) {\n const match = line.match(/^(\\d+)\\s(.*)$/)\n if (match) {\n const pid = match[1]!\n const cmd = match[2]!\n tree[parentPid]!.push(pid)\n tree[pid] = []\n outputDebug(`Killing process ${pid}: ${cmd}`)\n pidsToProcess.add(pid)\n buildProcessTree(pid, tree, pidsToProcess, spawnChildProcessesList, cb)\n }\n })\n }\n\n ps.on('close', onClose)\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { ConcurrentOutput, ConcurrentOutputContext, useConcurrentOutputContext, } from '../../../private/node/ui/components/ConcurrentOutput.js';
|
|
2
2
|
export { Alert } from '../../../private/node/ui/components/Alert.js';
|
|
3
3
|
export { Link } from '../../../private/node/ui/components/Link.js';
|
|
4
|
+
export { LoadingIndicator } from '../../../private/node/ui/components/LoadingIndicator.js';
|
|
4
5
|
export { TabularData } from '../../../private/node/ui/components/TabularData.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { ConcurrentOutput, useConcurrentOutputContext, } from '../../../private/node/ui/components/ConcurrentOutput.js';
|
|
2
2
|
export { Alert } from '../../../private/node/ui/components/Alert.js';
|
|
3
3
|
export { Link } from '../../../private/node/ui/components/Link.js';
|
|
4
|
+
export { LoadingIndicator } from '../../../private/node/ui/components/LoadingIndicator.js';
|
|
4
5
|
export { TabularData } from '../../../private/node/ui/components/TabularData.js';
|
|
5
6
|
//# sourceMappingURL=components.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../../../src/public/node/ui/components.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAEhB,0BAA0B,GAC3B,MAAM,yDAAyD,CAAA;AAChE,OAAO,EAAC,KAAK,EAAC,MAAM,8CAA8C,CAAA;AAClE,OAAO,EAAC,IAAI,EAAC,MAAM,6CAA6C,CAAA;AAChE,OAAO,EAAC,WAAW,EAAC,MAAM,oDAAoD,CAAA","sourcesContent":["export {\n ConcurrentOutput,\n ConcurrentOutputContext,\n useConcurrentOutputContext,\n} from '../../../private/node/ui/components/ConcurrentOutput.js'\nexport {Alert} from '../../../private/node/ui/components/Alert.js'\nexport {Link} from '../../../private/node/ui/components/Link.js'\nexport {TabularData} from '../../../private/node/ui/components/TabularData.js'\n"]}
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../../../src/public/node/ui/components.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAEhB,0BAA0B,GAC3B,MAAM,yDAAyD,CAAA;AAChE,OAAO,EAAC,KAAK,EAAC,MAAM,8CAA8C,CAAA;AAClE,OAAO,EAAC,IAAI,EAAC,MAAM,6CAA6C,CAAA;AAChE,OAAO,EAAC,gBAAgB,EAAC,MAAM,yDAAyD,CAAA;AACxF,OAAO,EAAC,WAAW,EAAC,MAAM,oDAAoD,CAAA","sourcesContent":["export {\n ConcurrentOutput,\n ConcurrentOutputContext,\n useConcurrentOutputContext,\n} from '../../../private/node/ui/components/ConcurrentOutput.js'\nexport {Alert} from '../../../private/node/ui/components/Alert.js'\nexport {Link} from '../../../private/node/ui/components/Link.js'\nexport {LoadingIndicator} from '../../../private/node/ui/components/LoadingIndicator.js'\nexport {TabularData} from '../../../private/node/ui/components/TabularData.js'\n"]}
|
package/dist/public/node/ui.d.ts
CHANGED
|
@@ -325,9 +325,9 @@ export interface RenderSingleTaskOptions<T> {
|
|
|
325
325
|
renderOptions?: RenderOptions;
|
|
326
326
|
}
|
|
327
327
|
/**
|
|
328
|
-
* Awaits a single task and displays a loading
|
|
328
|
+
* Awaits a single task and displays a loading indicator while it's in progress. The task's result is returned.
|
|
329
329
|
* @param options - Configuration object
|
|
330
|
-
* @param options.title - The initial title to display with the loading
|
|
330
|
+
* @param options.title - The initial title to display with the loading indicator
|
|
331
331
|
* @param options.task - The async task to execute. Receives an updateStatus callback to change the displayed title.
|
|
332
332
|
* @param options.retry - The number of additional attempts after a failure. Defaults to zero.
|
|
333
333
|
* @param options.renderOptions - Optional render configuration
|
|
@@ -375,10 +375,30 @@ export interface RenderDangerousConfirmationPromptOptions extends Omit<Dangerous
|
|
|
375
375
|
*
|
|
376
376
|
*/
|
|
377
377
|
export declare function renderDangerousConfirmationPrompt({ renderOptions, ...props }: RenderDangerousConfirmationPromptOptions, uiDebugOptions?: UIDebugOptions): Promise<boolean>;
|
|
378
|
-
|
|
378
|
+
interface KeypressOptions {
|
|
379
|
+
/**
|
|
380
|
+
* The keys that end the wait, for example `['\r']` for Enter. Other keys are ignored.
|
|
381
|
+
* Without this option, any key ends the wait.
|
|
382
|
+
*/
|
|
383
|
+
keys?: string[];
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Waits for a key to be pressed. Ctrl+C rejects with AbortSilentError, which terminates the process.
|
|
387
|
+
*
|
|
388
|
+
* Raw mode is set back to the state it had before the call. A command that keeps stdin raw for
|
|
389
|
+
* its own single-key shortcuts (for example `theme dev`) keeps them.
|
|
390
|
+
*
|
|
391
|
+
* Chunks are read as text: an active Ink renderer calls `stdin.setEncoding('utf8')`, and then
|
|
392
|
+
* stdin emits strings instead of Buffers.
|
|
393
|
+
*
|
|
394
|
+
* @param stdin - The stream to read from.
|
|
395
|
+
* @param uiDebugOptions - Debug options; `skipTTYCheck` allows a non-TTY stdin.
|
|
396
|
+
* @param options - The keys that end the wait.
|
|
397
|
+
* @returns A promise that resolves when an accepted key is pressed.
|
|
398
|
+
*/
|
|
379
399
|
export declare const keypress: (stdin?: NodeJS.ReadStream & {
|
|
380
400
|
fd: 0;
|
|
381
|
-
}, uiDebugOptions?: UIDebugOptions) => Promise<
|
|
401
|
+
}, uiDebugOptions?: UIDebugOptions, { keys }?: KeypressOptions) => Promise<void>;
|
|
382
402
|
interface IsTTYOptions {
|
|
383
403
|
stdin?: NodeJS.ReadStream;
|
|
384
404
|
uiDebugOptions?: UIDebugOptions;
|
package/dist/public/node/ui.js
CHANGED
|
@@ -7,10 +7,10 @@ import { terminalSupportsPrompting } from './system.js';
|
|
|
7
7
|
import { AbortController } from './abort.js';
|
|
8
8
|
import { runWithTimer } from './metadata.js';
|
|
9
9
|
import { ConcurrentOutput, runConcurrentProcessesForJson, } from '../../private/node/ui/components/ConcurrentOutput.js';
|
|
10
|
-
import { handleCtrlC, render, renderOnce } from '../../private/node/ui.js';
|
|
10
|
+
import { handleCtrlC, render, renderOnce, Stdout } from '../../private/node/ui.js';
|
|
11
11
|
import { alert } from '../../private/node/ui/alert.js';
|
|
12
12
|
import { FatalError } from '../../private/node/ui/components/FatalError.js';
|
|
13
|
-
import { Table } from '../../private/node/ui/components/Table/Table.js';
|
|
13
|
+
import { Table, tableWidth } from '../../private/node/ui/components/Table/Table.js';
|
|
14
14
|
import { tokenItemToString, } from '../../private/node/ui/components/token-item.js';
|
|
15
15
|
import { DangerousConfirmationPrompt, } from '../../private/node/ui/components/DangerousConfirmationPrompt.js';
|
|
16
16
|
import { SelectPrompt } from '../../private/node/ui/components/SelectPrompt.js';
|
|
@@ -375,8 +375,18 @@ export async function renderAutocompletePrompt({ renderOptions, ...props }, uiDe
|
|
|
375
375
|
* 3 John Smith jon@smith.com
|
|
376
376
|
*/
|
|
377
377
|
export function renderTable({ renderOptions, ...props }) {
|
|
378
|
-
return renderOnce(React.createElement(Table, { ...props }), { renderOptions });
|
|
378
|
+
return renderOnce(React.createElement(Table, { ...props }), { renderOptions: tableRenderOptions(props, renderOptions) });
|
|
379
379
|
}
|
|
380
|
+
// Output that isn't a terminal (a pipe, a file, a CI log) has no width, and Ink then lays the table out in 80
|
|
381
|
+
// columns, squeezing headers to "Typ" and wrapping cells onto extra lines. Give the table the width it needs
|
|
382
|
+
// instead; a terminal keeps its own width.
|
|
383
|
+
function tableRenderOptions(props, renderOptions) {
|
|
384
|
+
if (renderOptions?.stdout || process.stdout.columns !== undefined)
|
|
385
|
+
return renderOptions;
|
|
386
|
+
const columns = Math.max(DEFAULT_OUTPUT_COLUMNS, tableWidth(props));
|
|
387
|
+
return { ...renderOptions, stdout: new Stdout({ columns }) };
|
|
388
|
+
}
|
|
389
|
+
const DEFAULT_OUTPUT_COLUMNS = 80;
|
|
380
390
|
/**
|
|
381
391
|
* Runs async tasks and displays their progress to the console.
|
|
382
392
|
* @example
|
|
@@ -396,9 +406,9 @@ export async function renderTasks(tasks, { renderOptions, noProgressBar } = {})
|
|
|
396
406
|
return taskResult;
|
|
397
407
|
}
|
|
398
408
|
/**
|
|
399
|
-
* Awaits a single task and displays a loading
|
|
409
|
+
* Awaits a single task and displays a loading indicator while it's in progress. The task's result is returned.
|
|
400
410
|
* @param options - Configuration object
|
|
401
|
-
* @param options.title - The initial title to display with the loading
|
|
411
|
+
* @param options.title - The initial title to display with the loading indicator
|
|
402
412
|
* @param options.task - The async task to execute. Receives an updateStatus callback to change the displayed title.
|
|
403
413
|
* @param options.retry - The number of additional attempts after a failure. Defaults to zero.
|
|
404
414
|
* @param options.renderOptions - Optional render configuration
|
|
@@ -541,27 +551,50 @@ export async function renderDangerousConfirmationPrompt({ renderOptions, ...prop
|
|
|
541
551
|
return confirmed;
|
|
542
552
|
});
|
|
543
553
|
}
|
|
544
|
-
/**
|
|
545
|
-
|
|
554
|
+
/**
|
|
555
|
+
* Waits for a key to be pressed. Ctrl+C rejects with AbortSilentError, which terminates the process.
|
|
556
|
+
*
|
|
557
|
+
* Raw mode is set back to the state it had before the call. A command that keeps stdin raw for
|
|
558
|
+
* its own single-key shortcuts (for example `theme dev`) keeps them.
|
|
559
|
+
*
|
|
560
|
+
* Chunks are read as text: an active Ink renderer calls `stdin.setEncoding('utf8')`, and then
|
|
561
|
+
* stdin emits strings instead of Buffers.
|
|
562
|
+
*
|
|
563
|
+
* @param stdin - The stream to read from.
|
|
564
|
+
* @param uiDebugOptions - Debug options; `skipTTYCheck` allows a non-TTY stdin.
|
|
565
|
+
* @param options - The keys that end the wait.
|
|
566
|
+
* @returns A promise that resolves when an accepted key is pressed.
|
|
567
|
+
*/
|
|
568
|
+
export const keypress = async (stdin = process.stdin, uiDebugOptions = defaultUIDebugOptions, { keys } = {}) => {
|
|
546
569
|
throwInNonTTY({ message: 'Press any key' }, uiDebugOptions);
|
|
547
570
|
return runWithTimer('cmd_all_timing_prompts_ms')(() => {
|
|
548
|
-
|
|
549
|
-
|
|
571
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
572
|
+
const stdinWasRaw = stdin.isRaw === true;
|
|
573
|
+
const stopListening = () => {
|
|
574
|
+
stdin.off('data', handler);
|
|
575
|
+
if (!stdinWasRaw)
|
|
550
576
|
stdin.setRawMode(false);
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
577
|
+
stdin.unref();
|
|
578
|
+
};
|
|
579
|
+
const handler = (chunk) => {
|
|
580
|
+
const text = chunk.toString();
|
|
581
|
+
if (text.includes('\u0003')) {
|
|
582
|
+
stopListening();
|
|
583
|
+
outputDebug('Canceled keypress, User pressed CTRL+C');
|
|
584
|
+
reject(new AbortSilentError());
|
|
585
|
+
}
|
|
586
|
+
else if (!keys || [...text].some((character) => keys.includes(character))) {
|
|
587
|
+
stopListening();
|
|
557
588
|
process.nextTick(resolve);
|
|
558
|
-
}
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
if (!stdinWasRaw)
|
|
559
592
|
stdin.setRawMode(true);
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
593
|
+
stdin.on('data', handler);
|
|
594
|
+
// We want to indicate that we're still using stdin, so that the process
|
|
595
|
+
// doesn't exit early.
|
|
596
|
+
stdin.ref();
|
|
597
|
+
return promise;
|
|
565
598
|
});
|
|
566
599
|
};
|
|
567
600
|
export function isTTY({ stdin = undefined, uiDebugOptions = defaultUIDebugOptions } = {}) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAsB,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAC,sBAAsB,EAAE,gBAAgB,EAAC,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,WAAW,EAAmB,QAAQ,EAAC,M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AA;QACb,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAOD,MAAM,UAAU,KAAK,CAAC,EAAC,KAAK,GAAG,SAAS,EAAE,cAAc,GAAG,qBAAqB,KAAkB,EAAE;IAClG,wIAAwI;IACxI,OAAO,OAAO,CAAC,cAAc,CAAC,YAAY,IAAI,KAAK,IAAI,yBAAyB,EAAE,CAAC,CAAA;AACrF,CAAC;AAOD,SAAS,aAAa,CAAC,EAAC,OAAO,EAAE,KAAK,GAAG,SAAS,EAAuB,EAAE,cAA8B;IACvG,IAAI,KAAK,CAAC,EAAC,KAAK,EAAE,cAAc,EAAC,CAAC;QAAE,OAAM;IAE1C,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAA;IAC7C,MAAM,YAAY,GAAG;;EAErB,aAAa,CAAA,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK;;2IAEqF,CAAA;IACzI,MAAM,IAAI,UAAU,CAClB,YAAY,EACZ,mIAAmI,CACpI,CAAA;AACH,CAAC;AAID,OAAO,EAA2F,MAAM,EAAE,WAAW,EAAC,CAAA","sourcesContent":["/* eslint-disable tsdoc/syntax */\nimport {AbortError, AbortSilentError, FatalError as Fatal} from './error.js'\nimport {commandEventOutputMode, emitCommandEvent} from './command-events.js'\nimport {randomUUID} from './crypto.js'\nimport {outputContent, outputDebug, outputToken, TokenizedString, unstyled} from './output.js'\nimport {terminalSupportsPrompting} from './system.js'\nimport {AbortController} from './abort.js'\nimport {runWithTimer} from './metadata.js'\nimport {\n ConcurrentOutput,\n ConcurrentOutputProps,\n runConcurrentProcessesForJson,\n} from '../../private/node/ui/components/ConcurrentOutput.js'\nimport {handleCtrlC, render, renderOnce} from '../../private/node/ui.js'\nimport {alert, AlertOptions} from '../../private/node/ui/alert.js'\nimport {CustomSection} from '../../private/node/ui/components/Alert.js'\nimport {FatalError} from '../../private/node/ui/components/FatalError.js'\nimport ScalarDict from '../../private/node/ui/components/Table/ScalarDict.js'\nimport {Table, TableColumn, TableProps} from '../../private/node/ui/components/Table/Table.js'\nimport {\n tokenItemToString,\n type InlineToken,\n type LinkToken,\n type ListToken,\n type Token,\n type TokenItem,\n} from '../../private/node/ui/components/token-item.js'\nimport {\n DangerousConfirmationPrompt,\n DangerousConfirmationPromptProps,\n} from '../../private/node/ui/components/DangerousConfirmationPrompt.js'\nimport {SelectPrompt, SelectPromptProps} from '../../private/node/ui/components/SelectPrompt.js'\nimport {Tasks, Task} from '../../private/node/ui/components/Tasks.js'\nimport {runTasks} from '../../private/node/ui/tasks.js'\nimport {TextPrompt, TextPromptProps} from '../../private/node/ui/components/TextPrompt.js'\nimport {AutocompletePromptProps, AutocompletePrompt} from '../../private/node/ui/components/AutocompletePrompt.js'\nimport {InfoTableSection} from '../../private/node/ui/components/Prompts/InfoTable.js'\nimport {InfoMessageProps} from '../../private/node/ui/components/Prompts/InfoMessage.js'\nimport {SingleTask} from '../../private/node/ui/components/SingleTask.js'\n\nimport React from 'react'\nimport {Key as InkKey, RenderOptions} from 'ink'\n\ntype PartialBy<T, TKey extends keyof T> = Omit<T, TKey> & Partial<Pick<T, TKey>>\n\ninterface UIDebugOptions {\n /** If true, don't check if the current terminal is interactive or not */\n skipTTYCheck?: boolean\n}\nconst defaultUIDebugOptions: UIDebugOptions = {\n skipTTYCheck: false,\n}\n\nexport interface RenderConcurrentOptions extends PartialBy<ConcurrentOutputProps, 'abortSignal'> {\n /** Ink options for terminal UI. Finite JSON output uses the command event channel on stderr instead. */\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.\n * @example\n * 00:00:00 โ backend โ first backend message\n * 00:00:00 โ backend โ second backend message\n * 00:00:00 โ backend โ third backend message\n * 00:00:00 โ frontend โ first frontend message\n * 00:00:00 โ frontend โ second frontend message\n * 00:00:00 โ frontend โ third frontend message\n *\n */\nexport async function renderConcurrent({renderOptions, ...props}: RenderConcurrentOptions) {\n const abortSignal = props.abortSignal ?? new AbortController().signal\n\n // Streaming callers retain their existing Ink lifecycle; finite JSON results must keep stdout clear.\n if (commandEventOutputMode() === 'json' && !props.keepRunningAfterProcessesResolve) {\n if (props.processes.length === 0) return\n return renderSingleTask({\n title: outputContent`Running concurrent processes`,\n task: async () => runConcurrentProcessesForJson({...props, abortSignal}),\n })\n }\n\n return render(<ConcurrentOutput {...props} abortSignal={abortSignal} />, renderOptions)\n}\n\nexport type AlertCustomSection = CustomSection\nexport type RenderAlertOptions = Omit<AlertOptions, 'type'>\n\n/**\n * Renders an information banner to the console.\n * @example Basic\n * โญโ info โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ CLI update available. โ\n * โ โ\n * โ Run `npm run shopify upgrade`. โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n *\n * @example Complete\n * โญโ info โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ my-app initialized and ready to build. โ\n * โ โ\n * โ Next steps โ\n * โ โข Run `cd verification-app` โ\n * โ โข To preview your project, run `npm app dev` โ\n * โ โข To add extensions, run `npm generate extension` โ\n * โ โ\n * โ Reference โ\n * โ โข Run `npm shopify help` โ\n * โ โข Dev docs [1] โ\n * โ โ\n * โ Custom section โ\n * โ โข Item 1 [2] โ\n * โ โข Item 2 โ\n * โ โข Item 3 [3] โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n * [1] https://shopify.dev\n * [2] https://www.google.com/search?q=jh56t9l34kpo35tw8s28hn7s9s2xvzla01d8cn6j7yq&rlz=1C1GCEU_enUS832US832&oq=jh56t9l34kpo35tw8s28hn7s9s2xvzla01d8cn6j7yq&aqs=chrome.0.35i39l2j0l4j46j69i60.2711j0j7&sourceid=chrome&ie=UTF-8\n * [3] https://shopify.com\n *\n */\nexport function renderInfo(options: RenderAlertOptions) {\n return alert({...options, type: 'info'})\n}\n\n/**\n * Renders a success banner to the console.\n * @example Basic\n * โญโ success โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ CLI updated. โ\n * โ โ\n * โ You are now running version 3.47. โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n *\n * @example Complete\n * โญโ success โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ Deployment successful. โ\n * โ โ\n * โ Your extensions have been uploaded to your Shopify โ\n * โ Partners Dashboard. โ\n * โ โ\n * โ Next steps โ\n * โ โข See your deployment and set it live [1] โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n * [1] https://partners.shopify.com/1797046/apps/4523695/deployments\n *\n */\nexport function renderSuccess(options: RenderAlertOptions) {\n return alert({...options, type: 'success'})\n}\n\n/**\n * Renders a warning banner to the console.\n * @example Basic\n * โญโ warning โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ You have reached your limit of checkout extensions for โ\n * โ this app. โ\n * โ โ\n * โ You can free up space for a new one by deleting an โ\n * โ existing one. โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n *\n * @example Complete\n * โญโ warning โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ Required access scope update. โ\n * โ โ\n * โ The deadline for re-selecting your app scopes is May โ\n * โ 1, 2022. โ\n * โ โ\n * โ Reference โ\n * โ โข Dev docs [1] โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n * [1] https://shopify.dev/app/scopes\n *\n */\nexport function renderWarning(options: RenderAlertOptions) {\n return alert({...options, type: 'warning'})\n}\n\n/**\n * Renders an error banner to the console.\n * @example\n * โญโ error โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ Version couldn't be released. โ\n * โ โ\n * โ This version needs to be submitted for review and โ\n * โ approved by Shopify before it can be released. โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n *\n */\nexport function renderError(options: RenderAlertOptions) {\n return alert({...options, type: 'error'})\n}\n\ninterface RenderFatalErrorOptions {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a Fatal error to the console inside a banner.\n * @example Basic\n * โญโ error โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ Something went wrong. โ\n * โ โ\n * โ To investigate the issue, examine this stack trace: โ\n * โ at _compile (internal/modules/cjs/loader.js:1137) โ\n * โ at js (internal/modules/cjs/loader.js:1157) โ\n * โ at load (internal/modules/cjs/loader.js:985) โ\n * โ at _load (internal/modules/cjs/loader.js:878) โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n *\n * @example Complete\n * โญโ error โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ No Organization found โ\n * โ โ\n * โ Next steps โ\n * โ โข Have you created a Shopify Partners organization โ\n * โ [1]? โ\n * โ โข Have you confirmed your accounts from the emails โ\n * โ you received? โ\n * โ โข Need to connect to a different App or โ\n * โ organization? Run the command again with `--reset` โ\n * โ โ\n * โ amortizable-marketplace-ext โ\n * โ โข Some other error โ\n * โ Validation errors โ\n * โ โข Missing expected key(s). โ\n * โ โ\n * โ amortizable-marketplace-ext-2 โ\n * โ โข Something was not found โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n * [1] https://partners.shopify.com/signup\n *\n */\n\nexport function renderFatalError(error: Fatal, {renderOptions}: RenderFatalErrorOptions = {}) {\n return renderOnce(<FatalError error={error} />, {logLevel: 'error', renderOptions})\n}\n\nexport interface RenderSelectPromptOptions<T> extends Omit<SelectPromptProps<T>, 'onSubmit'> {\n isConfirmationPrompt?: boolean\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a select prompt to the console.\n * @example\n * ? Associate your project with the org Castile Ventures?\n *\n * โ Add\n * โ โข new-ext\n * โ\n * โ Remove\n * โ โข integrated-demand-ext\n * โ โข order-discount\n *\n * Automations\n * > fifth\n * sixth\n *\n * Merchant Admin\n * eighth\n * ninth\n *\n * Other\n * first\n * second\n * third (limit reached)\n * fourth\n * seventh\n * tenth\n *\n * Press โโ arrows to select, enter to confirm.\n *\n */\n\nexport async function renderSelectPrompt<T>(\n {renderOptions, isConfirmationPrompt, ...props}: RenderSelectPromptOptions<T>,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n): Promise<T> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin}, uiDebugOptions)\n\n return runWithTimer('cmd_all_timing_prompts_ms')(async () => {\n let selectedValue: T\n await render(\n <SelectPrompt\n {...props}\n onSubmit={(value: T) => {\n selectedValue = value\n }}\n />,\n {\n stdout: process.stderr as unknown as NodeJS.WriteStream,\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return selectedValue!\n })\n}\n\nexport interface RenderConfirmationPromptOptions extends Pick<\n SelectPromptProps<boolean>,\n 'message' | 'infoTable' | 'infoMessage' | 'abortSignal'\n> {\n confirmationMessage?: string\n cancellationMessage?: string\n renderOptions?: RenderOptions\n defaultValue?: boolean\n}\n\n/**\n * Renders a confirmation prompt to the console.\n * @example\n * ? Delete the following themes from the store?\n *\n * โ Info message title\n * โ\n * โ Info message body\n * โ\n * โ โข first theme (#1)\n * โ โข second theme (#2)\n *\n * > (y) Yes, confirm changes\n * (n) Cancel\n *\n * Press โโ arrows to select, enter or a shortcut to\n * confirm.\n *\n */\nexport async function renderConfirmationPrompt({\n message,\n infoTable,\n confirmationMessage = 'Yes, confirm',\n cancellationMessage = 'No, cancel',\n renderOptions,\n defaultValue = true,\n abortSignal,\n infoMessage,\n}: RenderConfirmationPromptOptions): Promise<boolean> {\n const choices = [\n {\n label: confirmationMessage,\n value: true,\n key: 'y',\n },\n {\n label: cancellationMessage,\n value: false,\n key: 'n',\n },\n ]\n\n return renderSelectPrompt({\n choices,\n message,\n infoTable,\n renderOptions,\n defaultValue,\n isConfirmationPrompt: true,\n abortSignal,\n infoMessage,\n })\n}\n\nexport interface RenderAutocompleteOptions<T> extends PartialBy<\n Omit<AutocompletePromptProps<T>, 'onSubmit'>,\n 'search'\n> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders an autocomplete prompt to the console.\n * @example\n * ? Select a template: Type to search...\n *\n * โ Info message title\n * โ\n * โ Info message body\n *\n * > first\n * second\n * third\n * fourth\n * fifth\n * sixth\n * seventh\n * eighth\n * ninth\n * tenth\n * eleventh\n * twelfth\n * thirteenth\n * fourteenth\n * fifteenth\n * sixteenth\n * seventeenth\n * eighteenth\n * nineteenth (disabled)\n * twentieth\n * twenty-first\n * twenty-second\n * twenty-third\n * twenty-fourth\n * twenty-fifth\n *\n * Press โโ arrows to select, enter to confirm.\n *\n */\n\nexport async function renderAutocompletePrompt<T>(\n {renderOptions, ...props}: RenderAutocompleteOptions<T>,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n): Promise<T> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin}, uiDebugOptions)\n\n // The default search filters in-memory choices synchronously, so it doesn't need\n // throttling. Skipping the throttle makes the keystroke-to-result latency feel\n // instant. Callers that supply their own (typically remote/paginated) search keep\n // the component's default throttle unless they opt out via `searchDebounceMs`.\n const usingDefaultSearch = props.search === undefined\n const newProps = {\n search(term: string) {\n const lowerTerm = term.toLowerCase()\n return Promise.resolve({\n data: props.choices.filter((item) => {\n return item.label.toLowerCase().includes(lowerTerm) || item.group?.toLowerCase().includes(lowerTerm)\n }),\n })\n },\n ...(usingDefaultSearch ? {searchDebounceMs: 0} : {}),\n ...props,\n }\n\n return runWithTimer('cmd_all_timing_prompts_ms')(async () => {\n let selectedValue: T | undefined\n await render(\n <AutocompletePrompt\n {...newProps}\n onSubmit={(value: T) => {\n selectedValue = value\n }}\n />,\n {\n stdout: process.stderr as unknown as NodeJS.WriteStream,\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n\n if (selectedValue === undefined) {\n throw new Error(\n 'Prompt was interrupted before a selection was made. This can happen if the process received a signal, was terminated, or the prompt was aborted.',\n )\n }\n\n return selectedValue\n })\n}\n\ninterface RenderTableOptions<T extends ScalarDict> extends TableProps<T> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a table to the console.\n * @example\n * ID Name email\n * โโ โโโโโโโโโโ โโโโโโโโโโโโโ\n * 1 John Doe jon@doe.com\n * 2 Jane Doe jane@doe.com\n * 3 John Smith jon@smith.com\n */\nexport function renderTable<T extends ScalarDict>({renderOptions, ...props}: RenderTableOptions<T>) {\n return renderOnce(<Table {...props} />, {renderOptions})\n}\n\ninterface RenderTasksOptions {\n renderOptions?: RenderOptions\n noProgressBar?: boolean\n}\n\n/**\n * Runs async tasks and displays their progress to the console.\n * @example\n * Installing dependencies ...\n */\n\nexport async function renderTasks<TContext>(\n tasks: Task<TContext>[],\n {renderOptions, noProgressBar}: RenderTasksOptions = {},\n): Promise<TContext> {\n if (commandEventOutputMode() === 'json') return runTasks(tasks)\n\n let taskResult: TContext\n await render(\n <Tasks\n tasks={tasks}\n onComplete={(ctx) => {\n taskResult = ctx\n }}\n noProgressBar={noProgressBar}\n />,\n {\n stdout: process.stderr as unknown as NodeJS.WriteStream,\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return taskResult!\n}\n\nexport interface RenderSingleTaskOptions<T> {\n title: TokenizedString\n task: (updateStatus: (status: TokenizedString) => void) => Promise<T>\n /** The number of additional attempts after a failure. Defaults to zero. */\n retry?: number\n onAbort?: () => void\n renderOptions?: RenderOptions\n}\n\n/**\n * Awaits a single task and displays a loading bar while it's in progress. The task's result is returned.\n * @param options - Configuration object\n * @param options.title - The initial title to display with the loading bar\n * @param options.task - The async task to execute. Receives an updateStatus callback to change the displayed title.\n * @param options.retry - The number of additional attempts after a failure. Defaults to zero.\n * @param options.renderOptions - Optional render configuration\n * @returns The result of the task\n * @example\n * Loading app ...\n */\nexport async function renderSingleTask<T>({\n title,\n task,\n retry = 0,\n onAbort,\n renderOptions,\n}: RenderSingleTaskOptions<T>): Promise<T> {\n // Keep updates correlated even when titles change or concurrent tasks share the same title.\n const operation = randomUUID()\n let currentStatus = title\n let aborted = false\n const abort = onAbort\n ? () => {\n aborted = true\n onAbort()\n }\n : undefined\n const taskWithProgressEvents = async (updateStatus: (status: TokenizedString) => void): Promise<T> => {\n emitCommandEvent(\n {type: 'progress', operation, status: 'started', message: unstyled(currentStatus.value)},\n {alreadyRendered: true},\n )\n const updateTaskStatus = (status: TokenizedString) => {\n currentStatus = status\n emitCommandEvent(\n {type: 'progress', operation, status: 'updated', message: unstyled(status.value)},\n {alreadyRendered: true},\n )\n updateStatus(status)\n }\n\n for (let attempt = 0; ; attempt++) {\n let result: T\n try {\n // eslint-disable-next-line no-await-in-loop\n result = await task(updateTaskStatus)\n } catch (error) {\n // A custom abort callback can reject the task; cancellation must not start another attempt.\n if (aborted) throw error\n\n const shouldRetry = attempt < retry\n emitCommandEvent(\n {\n type: 'progress',\n operation,\n status: shouldRetry ? 'retrying' : 'failed',\n message: unstyled(currentStatus.value),\n },\n {alreadyRendered: true},\n )\n if (!shouldRetry) throw error\n continue\n }\n\n if (!aborted) {\n emitCommandEvent(\n {\n type: 'progress',\n operation,\n status: 'completed',\n message: unstyled(currentStatus.value),\n current: 1,\n total: 1,\n },\n {alreadyRendered: true},\n )\n }\n return result\n }\n }\n\n if (commandEventOutputMode() === 'json') {\n // Without Ink's raw input handling, Ctrl+C arrives as SIGINT. Leave the default\n // signal behavior intact when the caller has no custom abort callback.\n const onSigint = () => abort?.()\n if (onAbort) process.once('SIGINT', onSigint)\n try {\n return await taskWithProgressEvents(() => {})\n } finally {\n if (onAbort) process.removeListener('SIGINT', onSigint)\n }\n }\n\n let taskResult: T\n await render(\n <SingleTask\n title={title}\n task={taskWithProgressEvents}\n onComplete={(result) => {\n taskResult = result\n }}\n onAbort={abort}\n />,\n {\n stdout: process.stderr as unknown as NodeJS.WriteStream,\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return taskResult!\n}\n\nexport interface RenderTextPromptOptions extends Omit<TextPromptProps, 'onSubmit'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a text prompt to the console.\n * @example\n * ? App project name (can be changed later):\n * > expansive commerce app\n * โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n *\n */\n\nexport async function renderTextPrompt(\n {renderOptions, ...props}: RenderTextPromptOptions,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n): Promise<string> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin}, uiDebugOptions)\n\n return runWithTimer('cmd_all_timing_prompts_ms')(async () => {\n let enteredText = ''\n await render(\n <TextPrompt\n {...props}\n onSubmit={(value: string) => {\n enteredText = value\n }}\n />,\n {\n stdout: process.stderr as unknown as NodeJS.WriteStream,\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return enteredText\n })\n}\n\nexport interface RenderDangerousConfirmationPromptOptions extends Omit<DangerousConfirmationPromptProps, 'onSubmit'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a dangerous confirmation prompt to the console, forcing the user to\n * type a confirmation string to proceed.\n * @example\n * ? Release a new version of nightly-app-2023-06-19?\n *\n * โ Includes:\n * โ + web-px (new)\n * โ + sub-ui-ext\n * โ + theme-app-ext\n * โ + paymentify (from Partner Dashboard)\n * โ\n * โ Removes:\n * โ - prod-discount-fun\n * โ\n * โ This can permanently delete app user data.\n *\n * Type nightly-app-2023-06-19 to confirm, or press Escape\n * to cancel.\n * > โ\n * โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n *\n */\n\nexport async function renderDangerousConfirmationPrompt(\n {renderOptions, ...props}: RenderDangerousConfirmationPromptOptions,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n): Promise<boolean> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin}, uiDebugOptions)\n\n return runWithTimer('cmd_all_timing_prompts_ms')(async () => {\n let confirmed: boolean\n await render(\n <DangerousConfirmationPrompt\n {...props}\n onSubmit={(value: boolean) => {\n confirmed = value\n }}\n />,\n {\n stdout: process.stderr as unknown as NodeJS.WriteStream,\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return confirmed!\n })\n}\n\n/** Waits for any key to be pressed except Ctrl+C which will terminate the process. */\n\nexport const keypress = async (stdin = process.stdin, uiDebugOptions: UIDebugOptions = defaultUIDebugOptions) => {\n throwInNonTTY({message: 'Press any key'}, uiDebugOptions)\n\n return runWithTimer('cmd_all_timing_prompts_ms')(() => {\n return new Promise((resolve, reject) => {\n const handler = (buffer: Buffer) => {\n stdin.setRawMode(false)\n\n const bytes = Array.from(buffer)\n\n if (bytes.length && bytes[0] === 3) {\n outputDebug('Canceled keypress, User pressed CTRL+C')\n reject(new AbortSilentError())\n }\n stdin.unref()\n process.nextTick(resolve)\n }\n\n stdin.setRawMode(true)\n stdin.once('data', handler)\n\n // We want to indicate that we're still using stdin, so that the process\n // doesn't exit early.\n stdin.ref()\n })\n })\n}\n\ninterface IsTTYOptions {\n stdin?: NodeJS.ReadStream\n uiDebugOptions?: UIDebugOptions\n}\n\nexport function isTTY({stdin = undefined, uiDebugOptions = defaultUIDebugOptions}: IsTTYOptions = {}) {\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- false should fall through to stdin/terminalSupportsPrompting\n return Boolean(uiDebugOptions.skipTTYCheck || stdin || terminalSupportsPrompting())\n}\n\ninterface ThrowInNonTTYOptions {\n message: TokenItem\n stdin?: NodeJS.ReadStream\n}\n\nfunction throwInNonTTY({message, stdin = undefined}: ThrowInNonTTYOptions, uiDebugOptions: UIDebugOptions) {\n if (isTTY({stdin, uiDebugOptions})) return\n\n const promptText = tokenItemToString(message)\n const errorMessage = `Failed to prompt:\n\n${outputContent`${outputToken.cyan(promptText)}`.value}\n\nThis usually happens when running a command non-interactively, for example in a CI environment, or when piping to or from another process.`\n throw new AbortError(\n errorMessage,\n 'To resolve this, specify the option in the command, or run the command in an interactive environment such as your local terminal.',\n )\n}\n\nexport type Key = InkKey\nexport type InfoMessage = InfoMessageProps['message']\nexport {Token, Task, TokenItem, InlineToken, LinkToken, TableColumn, InfoTableSection, ListToken, render, handleCtrlC}\n"]}
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAsB,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAC,sBAAsB,EAAE,gBAAgB,EAAC,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,WAAW,EAAmB,QAAQ,EAAC,MAAM,aAAa,CAAA;AAC9F,OAAO,EAAC,yBAAyB,EAAC,MAAM,aAAa,CAAA;AACrD,OAAO,EAAC,eAAe,EAAC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uB,EAAE,cAA8B;IACvG,IAAI,KAAK,CAAC,EAAC,KAAK,EAAE,cAAc,EAAC,CAAC;QAAE,OAAM;IAE1C,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAA;IAC7C,MAAM,YAAY,GAAG;;EAErB,aAAa,CAAA,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK;;2IAEqF,CAAA;IACzI,MAAM,IAAI,UAAU,CAClB,YAAY,EACZ,mIAAmI,CACpI,CAAA;AACH,CAAC;AAID,OAAO,EAA2F,MAAM,EAAE,WAAW,EAAC,CAAA","sourcesContent":["/* eslint-disable tsdoc/syntax */\nimport {AbortError, AbortSilentError, FatalError as Fatal} from './error.js'\nimport {commandEventOutputMode, emitCommandEvent} from './command-events.js'\nimport {randomUUID} from './crypto.js'\nimport {outputContent, outputDebug, outputToken, TokenizedString, unstyled} from './output.js'\nimport {terminalSupportsPrompting} from './system.js'\nimport {AbortController} from './abort.js'\nimport {runWithTimer} from './metadata.js'\nimport {\n ConcurrentOutput,\n ConcurrentOutputProps,\n runConcurrentProcessesForJson,\n} from '../../private/node/ui/components/ConcurrentOutput.js'\nimport {handleCtrlC, render, renderOnce, Stdout} from '../../private/node/ui.js'\nimport {alert, AlertOptions} from '../../private/node/ui/alert.js'\nimport {CustomSection} from '../../private/node/ui/components/Alert.js'\nimport {FatalError} from '../../private/node/ui/components/FatalError.js'\nimport ScalarDict from '../../private/node/ui/components/Table/ScalarDict.js'\nimport {Table, TableColumn, TableProps, tableWidth} from '../../private/node/ui/components/Table/Table.js'\nimport {\n tokenItemToString,\n type InlineToken,\n type LinkToken,\n type ListToken,\n type Token,\n type TokenItem,\n} from '../../private/node/ui/components/token-item.js'\nimport {\n DangerousConfirmationPrompt,\n DangerousConfirmationPromptProps,\n} from '../../private/node/ui/components/DangerousConfirmationPrompt.js'\nimport {SelectPrompt, SelectPromptProps} from '../../private/node/ui/components/SelectPrompt.js'\nimport {Tasks, Task} from '../../private/node/ui/components/Tasks.js'\nimport {runTasks} from '../../private/node/ui/tasks.js'\nimport {TextPrompt, TextPromptProps} from '../../private/node/ui/components/TextPrompt.js'\nimport {AutocompletePromptProps, AutocompletePrompt} from '../../private/node/ui/components/AutocompletePrompt.js'\nimport {InfoTableSection} from '../../private/node/ui/components/Prompts/InfoTable.js'\nimport {InfoMessageProps} from '../../private/node/ui/components/Prompts/InfoMessage.js'\nimport {SingleTask} from '../../private/node/ui/components/SingleTask.js'\n\nimport React from 'react'\nimport {Key as InkKey, RenderOptions} from 'ink'\n\ntype PartialBy<T, TKey extends keyof T> = Omit<T, TKey> & Partial<Pick<T, TKey>>\n\ninterface UIDebugOptions {\n /** If true, don't check if the current terminal is interactive or not */\n skipTTYCheck?: boolean\n}\nconst defaultUIDebugOptions: UIDebugOptions = {\n skipTTYCheck: false,\n}\n\nexport interface RenderConcurrentOptions extends PartialBy<ConcurrentOutputProps, 'abortSignal'> {\n /** Ink options for terminal UI. Finite JSON output uses the command event channel on stderr instead. */\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.\n * @example\n * 00:00:00 โ backend โ first backend message\n * 00:00:00 โ backend โ second backend message\n * 00:00:00 โ backend โ third backend message\n * 00:00:00 โ frontend โ first frontend message\n * 00:00:00 โ frontend โ second frontend message\n * 00:00:00 โ frontend โ third frontend message\n *\n */\nexport async function renderConcurrent({renderOptions, ...props}: RenderConcurrentOptions) {\n const abortSignal = props.abortSignal ?? new AbortController().signal\n\n // Streaming callers retain their existing Ink lifecycle; finite JSON results must keep stdout clear.\n if (commandEventOutputMode() === 'json' && !props.keepRunningAfterProcessesResolve) {\n if (props.processes.length === 0) return\n return renderSingleTask({\n title: outputContent`Running concurrent processes`,\n task: async () => runConcurrentProcessesForJson({...props, abortSignal}),\n })\n }\n\n return render(<ConcurrentOutput {...props} abortSignal={abortSignal} />, renderOptions)\n}\n\nexport type AlertCustomSection = CustomSection\nexport type RenderAlertOptions = Omit<AlertOptions, 'type'>\n\n/**\n * Renders an information banner to the console.\n * @example Basic\n * โญโ info โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ CLI update available. โ\n * โ โ\n * โ Run `npm run shopify upgrade`. โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n *\n * @example Complete\n * โญโ info โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ my-app initialized and ready to build. โ\n * โ โ\n * โ Next steps โ\n * โ โข Run `cd verification-app` โ\n * โ โข To preview your project, run `npm app dev` โ\n * โ โข To add extensions, run `npm generate extension` โ\n * โ โ\n * โ Reference โ\n * โ โข Run `npm shopify help` โ\n * โ โข Dev docs [1] โ\n * โ โ\n * โ Custom section โ\n * โ โข Item 1 [2] โ\n * โ โข Item 2 โ\n * โ โข Item 3 [3] โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n * [1] https://shopify.dev\n * [2] https://www.google.com/search?q=jh56t9l34kpo35tw8s28hn7s9s2xvzla01d8cn6j7yq&rlz=1C1GCEU_enUS832US832&oq=jh56t9l34kpo35tw8s28hn7s9s2xvzla01d8cn6j7yq&aqs=chrome.0.35i39l2j0l4j46j69i60.2711j0j7&sourceid=chrome&ie=UTF-8\n * [3] https://shopify.com\n *\n */\nexport function renderInfo(options: RenderAlertOptions) {\n return alert({...options, type: 'info'})\n}\n\n/**\n * Renders a success banner to the console.\n * @example Basic\n * โญโ success โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ CLI updated. โ\n * โ โ\n * โ You are now running version 3.47. โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n *\n * @example Complete\n * โญโ success โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ Deployment successful. โ\n * โ โ\n * โ Your extensions have been uploaded to your Shopify โ\n * โ Partners Dashboard. โ\n * โ โ\n * โ Next steps โ\n * โ โข See your deployment and set it live [1] โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n * [1] https://partners.shopify.com/1797046/apps/4523695/deployments\n *\n */\nexport function renderSuccess(options: RenderAlertOptions) {\n return alert({...options, type: 'success'})\n}\n\n/**\n * Renders a warning banner to the console.\n * @example Basic\n * โญโ warning โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ You have reached your limit of checkout extensions for โ\n * โ this app. โ\n * โ โ\n * โ You can free up space for a new one by deleting an โ\n * โ existing one. โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n *\n * @example Complete\n * โญโ warning โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ Required access scope update. โ\n * โ โ\n * โ The deadline for re-selecting your app scopes is May โ\n * โ 1, 2022. โ\n * โ โ\n * โ Reference โ\n * โ โข Dev docs [1] โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n * [1] https://shopify.dev/app/scopes\n *\n */\nexport function renderWarning(options: RenderAlertOptions) {\n return alert({...options, type: 'warning'})\n}\n\n/**\n * Renders an error banner to the console.\n * @example\n * โญโ error โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ Version couldn't be released. โ\n * โ โ\n * โ This version needs to be submitted for review and โ\n * โ approved by Shopify before it can be released. โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n *\n */\nexport function renderError(options: RenderAlertOptions) {\n return alert({...options, type: 'error'})\n}\n\ninterface RenderFatalErrorOptions {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a Fatal error to the console inside a banner.\n * @example Basic\n * โญโ error โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ Something went wrong. โ\n * โ โ\n * โ To investigate the issue, examine this stack trace: โ\n * โ at _compile (internal/modules/cjs/loader.js:1137) โ\n * โ at js (internal/modules/cjs/loader.js:1157) โ\n * โ at load (internal/modules/cjs/loader.js:985) โ\n * โ at _load (internal/modules/cjs/loader.js:878) โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n *\n * @example Complete\n * โญโ error โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ\n * โ โ\n * โ No Organization found โ\n * โ โ\n * โ Next steps โ\n * โ โข Have you created a Shopify Partners organization โ\n * โ [1]? โ\n * โ โข Have you confirmed your accounts from the emails โ\n * โ you received? โ\n * โ โข Need to connect to a different App or โ\n * โ organization? Run the command again with `--reset` โ\n * โ โ\n * โ amortizable-marketplace-ext โ\n * โ โข Some other error โ\n * โ Validation errors โ\n * โ โข Missing expected key(s). โ\n * โ โ\n * โ amortizable-marketplace-ext-2 โ\n * โ โข Something was not found โ\n * โ โ\n * โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ\n * [1] https://partners.shopify.com/signup\n *\n */\n\nexport function renderFatalError(error: Fatal, {renderOptions}: RenderFatalErrorOptions = {}) {\n return renderOnce(<FatalError error={error} />, {logLevel: 'error', renderOptions})\n}\n\nexport interface RenderSelectPromptOptions<T> extends Omit<SelectPromptProps<T>, 'onSubmit'> {\n isConfirmationPrompt?: boolean\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a select prompt to the console.\n * @example\n * ? Associate your project with the org Castile Ventures?\n *\n * โ Add\n * โ โข new-ext\n * โ\n * โ Remove\n * โ โข integrated-demand-ext\n * โ โข order-discount\n *\n * Automations\n * > fifth\n * sixth\n *\n * Merchant Admin\n * eighth\n * ninth\n *\n * Other\n * first\n * second\n * third (limit reached)\n * fourth\n * seventh\n * tenth\n *\n * Press โโ arrows to select, enter to confirm.\n *\n */\n\nexport async function renderSelectPrompt<T>(\n {renderOptions, isConfirmationPrompt, ...props}: RenderSelectPromptOptions<T>,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n): Promise<T> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin}, uiDebugOptions)\n\n return runWithTimer('cmd_all_timing_prompts_ms')(async () => {\n let selectedValue: T\n await render(\n <SelectPrompt\n {...props}\n onSubmit={(value: T) => {\n selectedValue = value\n }}\n />,\n {\n stdout: process.stderr as unknown as NodeJS.WriteStream,\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return selectedValue!\n })\n}\n\nexport interface RenderConfirmationPromptOptions extends Pick<\n SelectPromptProps<boolean>,\n 'message' | 'infoTable' | 'infoMessage' | 'abortSignal'\n> {\n confirmationMessage?: string\n cancellationMessage?: string\n renderOptions?: RenderOptions\n defaultValue?: boolean\n}\n\n/**\n * Renders a confirmation prompt to the console.\n * @example\n * ? Delete the following themes from the store?\n *\n * โ Info message title\n * โ\n * โ Info message body\n * โ\n * โ โข first theme (#1)\n * โ โข second theme (#2)\n *\n * > (y) Yes, confirm changes\n * (n) Cancel\n *\n * Press โโ arrows to select, enter or a shortcut to\n * confirm.\n *\n */\nexport async function renderConfirmationPrompt({\n message,\n infoTable,\n confirmationMessage = 'Yes, confirm',\n cancellationMessage = 'No, cancel',\n renderOptions,\n defaultValue = true,\n abortSignal,\n infoMessage,\n}: RenderConfirmationPromptOptions): Promise<boolean> {\n const choices = [\n {\n label: confirmationMessage,\n value: true,\n key: 'y',\n },\n {\n label: cancellationMessage,\n value: false,\n key: 'n',\n },\n ]\n\n return renderSelectPrompt({\n choices,\n message,\n infoTable,\n renderOptions,\n defaultValue,\n isConfirmationPrompt: true,\n abortSignal,\n infoMessage,\n })\n}\n\nexport interface RenderAutocompleteOptions<T> extends PartialBy<\n Omit<AutocompletePromptProps<T>, 'onSubmit'>,\n 'search'\n> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders an autocomplete prompt to the console.\n * @example\n * ? Select a template: Type to search...\n *\n * โ Info message title\n * โ\n * โ Info message body\n *\n * > first\n * second\n * third\n * fourth\n * fifth\n * sixth\n * seventh\n * eighth\n * ninth\n * tenth\n * eleventh\n * twelfth\n * thirteenth\n * fourteenth\n * fifteenth\n * sixteenth\n * seventeenth\n * eighteenth\n * nineteenth (disabled)\n * twentieth\n * twenty-first\n * twenty-second\n * twenty-third\n * twenty-fourth\n * twenty-fifth\n *\n * Press โโ arrows to select, enter to confirm.\n *\n */\n\nexport async function renderAutocompletePrompt<T>(\n {renderOptions, ...props}: RenderAutocompleteOptions<T>,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n): Promise<T> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin}, uiDebugOptions)\n\n // The default search filters in-memory choices synchronously, so it doesn't need\n // throttling. Skipping the throttle makes the keystroke-to-result latency feel\n // instant. Callers that supply their own (typically remote/paginated) search keep\n // the component's default throttle unless they opt out via `searchDebounceMs`.\n const usingDefaultSearch = props.search === undefined\n const newProps = {\n search(term: string) {\n const lowerTerm = term.toLowerCase()\n return Promise.resolve({\n data: props.choices.filter((item) => {\n return item.label.toLowerCase().includes(lowerTerm) || item.group?.toLowerCase().includes(lowerTerm)\n }),\n })\n },\n ...(usingDefaultSearch ? {searchDebounceMs: 0} : {}),\n ...props,\n }\n\n return runWithTimer('cmd_all_timing_prompts_ms')(async () => {\n let selectedValue: T | undefined\n await render(\n <AutocompletePrompt\n {...newProps}\n onSubmit={(value: T) => {\n selectedValue = value\n }}\n />,\n {\n stdout: process.stderr as unknown as NodeJS.WriteStream,\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n\n if (selectedValue === undefined) {\n throw new Error(\n 'Prompt was interrupted before a selection was made. This can happen if the process received a signal, was terminated, or the prompt was aborted.',\n )\n }\n\n return selectedValue\n })\n}\n\ninterface RenderTableOptions<T extends ScalarDict> extends TableProps<T> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a table to the console.\n * @example\n * ID Name email\n * โโ โโโโโโโโโโ โโโโโโโโโโโโโ\n * 1 John Doe jon@doe.com\n * 2 Jane Doe jane@doe.com\n * 3 John Smith jon@smith.com\n */\nexport function renderTable<T extends ScalarDict>({renderOptions, ...props}: RenderTableOptions<T>) {\n return renderOnce(<Table {...props} />, {renderOptions: tableRenderOptions(props, renderOptions)})\n}\n\n// Output that isn't a terminal (a pipe, a file, a CI log) has no width, and Ink then lays the table out in 80\n// columns, squeezing headers to \"Typ\" and wrapping cells onto extra lines. Give the table the width it needs\n// instead; a terminal keeps its own width.\nfunction tableRenderOptions<T extends ScalarDict>(\n props: TableProps<T>,\n renderOptions: RenderOptions | undefined,\n): RenderOptions | undefined {\n if (renderOptions?.stdout || process.stdout.columns !== undefined) return renderOptions\n const columns = Math.max(DEFAULT_OUTPUT_COLUMNS, tableWidth(props))\n return {...renderOptions, stdout: new Stdout({columns}) as unknown as NodeJS.WriteStream}\n}\n\nconst DEFAULT_OUTPUT_COLUMNS = 80\n\ninterface RenderTasksOptions {\n renderOptions?: RenderOptions\n noProgressBar?: boolean\n}\n\n/**\n * Runs async tasks and displays their progress to the console.\n * @example\n * Installing dependencies ...\n */\n\nexport async function renderTasks<TContext>(\n tasks: Task<TContext>[],\n {renderOptions, noProgressBar}: RenderTasksOptions = {},\n): Promise<TContext> {\n if (commandEventOutputMode() === 'json') return runTasks(tasks)\n\n let taskResult: TContext\n await render(\n <Tasks\n tasks={tasks}\n onComplete={(ctx) => {\n taskResult = ctx\n }}\n noProgressBar={noProgressBar}\n />,\n {\n stdout: process.stderr as unknown as NodeJS.WriteStream,\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return taskResult!\n}\n\nexport interface RenderSingleTaskOptions<T> {\n title: TokenizedString\n task: (updateStatus: (status: TokenizedString) => void) => Promise<T>\n /** The number of additional attempts after a failure. Defaults to zero. */\n retry?: number\n onAbort?: () => void\n renderOptions?: RenderOptions\n}\n\n/**\n * Awaits a single task and displays a loading indicator while it's in progress. The task's result is returned.\n * @param options - Configuration object\n * @param options.title - The initial title to display with the loading indicator\n * @param options.task - The async task to execute. Receives an updateStatus callback to change the displayed title.\n * @param options.retry - The number of additional attempts after a failure. Defaults to zero.\n * @param options.renderOptions - Optional render configuration\n * @returns The result of the task\n * @example\n * Loading app ...\n */\nexport async function renderSingleTask<T>({\n title,\n task,\n retry = 0,\n onAbort,\n renderOptions,\n}: RenderSingleTaskOptions<T>): Promise<T> {\n // Keep updates correlated even when titles change or concurrent tasks share the same title.\n const operation = randomUUID()\n let currentStatus = title\n let aborted = false\n const abort = onAbort\n ? () => {\n aborted = true\n onAbort()\n }\n : undefined\n const taskWithProgressEvents = async (updateStatus: (status: TokenizedString) => void): Promise<T> => {\n emitCommandEvent(\n {type: 'progress', operation, status: 'started', message: unstyled(currentStatus.value)},\n {alreadyRendered: true},\n )\n const updateTaskStatus = (status: TokenizedString) => {\n currentStatus = status\n emitCommandEvent(\n {type: 'progress', operation, status: 'updated', message: unstyled(status.value)},\n {alreadyRendered: true},\n )\n updateStatus(status)\n }\n\n for (let attempt = 0; ; attempt++) {\n let result: T\n try {\n // eslint-disable-next-line no-await-in-loop\n result = await task(updateTaskStatus)\n } catch (error) {\n // A custom abort callback can reject the task; cancellation must not start another attempt.\n if (aborted) throw error\n\n const shouldRetry = attempt < retry\n emitCommandEvent(\n {\n type: 'progress',\n operation,\n status: shouldRetry ? 'retrying' : 'failed',\n message: unstyled(currentStatus.value),\n },\n {alreadyRendered: true},\n )\n if (!shouldRetry) throw error\n continue\n }\n\n if (!aborted) {\n emitCommandEvent(\n {\n type: 'progress',\n operation,\n status: 'completed',\n message: unstyled(currentStatus.value),\n current: 1,\n total: 1,\n },\n {alreadyRendered: true},\n )\n }\n return result\n }\n }\n\n if (commandEventOutputMode() === 'json') {\n // Without Ink's raw input handling, Ctrl+C arrives as SIGINT. Leave the default\n // signal behavior intact when the caller has no custom abort callback.\n const onSigint = () => abort?.()\n if (onAbort) process.once('SIGINT', onSigint)\n try {\n return await taskWithProgressEvents(() => {})\n } finally {\n if (onAbort) process.removeListener('SIGINT', onSigint)\n }\n }\n\n let taskResult: T\n await render(\n <SingleTask\n title={title}\n task={taskWithProgressEvents}\n onComplete={(result) => {\n taskResult = result\n }}\n onAbort={abort}\n />,\n {\n stdout: process.stderr as unknown as NodeJS.WriteStream,\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return taskResult!\n}\n\nexport interface RenderTextPromptOptions extends Omit<TextPromptProps, 'onSubmit'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a text prompt to the console.\n * @example\n * ? App project name (can be changed later):\n * > expansive commerce app\n * โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n *\n */\n\nexport async function renderTextPrompt(\n {renderOptions, ...props}: RenderTextPromptOptions,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n): Promise<string> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin}, uiDebugOptions)\n\n return runWithTimer('cmd_all_timing_prompts_ms')(async () => {\n let enteredText = ''\n await render(\n <TextPrompt\n {...props}\n onSubmit={(value: string) => {\n enteredText = value\n }}\n />,\n {\n stdout: process.stderr as unknown as NodeJS.WriteStream,\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return enteredText\n })\n}\n\nexport interface RenderDangerousConfirmationPromptOptions extends Omit<DangerousConfirmationPromptProps, 'onSubmit'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a dangerous confirmation prompt to the console, forcing the user to\n * type a confirmation string to proceed.\n * @example\n * ? Release a new version of nightly-app-2023-06-19?\n *\n * โ Includes:\n * โ + web-px (new)\n * โ + sub-ui-ext\n * โ + theme-app-ext\n * โ + paymentify (from Partner Dashboard)\n * โ\n * โ Removes:\n * โ - prod-discount-fun\n * โ\n * โ This can permanently delete app user data.\n *\n * Type nightly-app-2023-06-19 to confirm, or press Escape\n * to cancel.\n * > โ\n * โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n *\n */\n\nexport async function renderDangerousConfirmationPrompt(\n {renderOptions, ...props}: RenderDangerousConfirmationPromptOptions,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n): Promise<boolean> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin}, uiDebugOptions)\n\n return runWithTimer('cmd_all_timing_prompts_ms')(async () => {\n let confirmed: boolean\n await render(\n <DangerousConfirmationPrompt\n {...props}\n onSubmit={(value: boolean) => {\n confirmed = value\n }}\n />,\n {\n stdout: process.stderr as unknown as NodeJS.WriteStream,\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return confirmed!\n })\n}\n\ninterface KeypressOptions {\n /**\n * The keys that end the wait, for example `['\\r']` for Enter. Other keys are ignored.\n * Without this option, any key ends the wait.\n */\n keys?: string[]\n}\n\n/**\n * Waits for a key to be pressed. Ctrl+C rejects with AbortSilentError, which terminates the process.\n *\n * Raw mode is set back to the state it had before the call. A command that keeps stdin raw for\n * its own single-key shortcuts (for example `theme dev`) keeps them.\n *\n * Chunks are read as text: an active Ink renderer calls `stdin.setEncoding('utf8')`, and then\n * stdin emits strings instead of Buffers.\n *\n * @param stdin - The stream to read from.\n * @param uiDebugOptions - Debug options; `skipTTYCheck` allows a non-TTY stdin.\n * @param options - The keys that end the wait.\n * @returns A promise that resolves when an accepted key is pressed.\n */\nexport const keypress = async (\n stdin = process.stdin,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n {keys}: KeypressOptions = {},\n) => {\n throwInNonTTY({message: 'Press any key'}, uiDebugOptions)\n\n return runWithTimer('cmd_all_timing_prompts_ms')(() => {\n const {promise, resolve, reject} = Promise.withResolvers<void>()\n const stdinWasRaw = stdin.isRaw === true\n\n const stopListening = () => {\n stdin.off('data', handler)\n if (!stdinWasRaw) stdin.setRawMode(false)\n stdin.unref()\n }\n\n const handler = (chunk: Buffer | string) => {\n const text = chunk.toString()\n if (text.includes('\\u0003')) {\n stopListening()\n outputDebug('Canceled keypress, User pressed CTRL+C')\n reject(new AbortSilentError())\n } else if (!keys || [...text].some((character) => keys.includes(character))) {\n stopListening()\n process.nextTick(resolve)\n }\n }\n\n if (!stdinWasRaw) stdin.setRawMode(true)\n stdin.on('data', handler)\n\n // We want to indicate that we're still using stdin, so that the process\n // doesn't exit early.\n stdin.ref()\n return promise\n })\n}\n\ninterface IsTTYOptions {\n stdin?: NodeJS.ReadStream\n uiDebugOptions?: UIDebugOptions\n}\n\nexport function isTTY({stdin = undefined, uiDebugOptions = defaultUIDebugOptions}: IsTTYOptions = {}) {\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- false should fall through to stdin/terminalSupportsPrompting\n return Boolean(uiDebugOptions.skipTTYCheck || stdin || terminalSupportsPrompting())\n}\n\ninterface ThrowInNonTTYOptions {\n message: TokenItem\n stdin?: NodeJS.ReadStream\n}\n\nfunction throwInNonTTY({message, stdin = undefined}: ThrowInNonTTYOptions, uiDebugOptions: UIDebugOptions) {\n if (isTTY({stdin, uiDebugOptions})) return\n\n const promptText = tokenItemToString(message)\n const errorMessage = `Failed to prompt:\n\n${outputContent`${outputToken.cyan(promptText)}`.value}\n\nThis usually happens when running a command non-interactively, for example in a CI environment, or when piping to or from another process.`\n throw new AbortError(\n errorMessage,\n 'To resolve this, specify the option in the command, or run the command in an interactive environment such as your local terminal.',\n )\n}\n\nexport type Key = InkKey\nexport type InfoMessage = InfoMessageProps['message']\nexport {Token, Task, TokenItem, InlineToken, LinkToken, TableColumn, InfoTableSection, ListToken, render, handleCtrlC}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Writable } from 'node:stream';
|
|
2
|
+
/**
|
|
3
|
+
* Keeps package-manager output off the result channel in JSON mode.
|
|
4
|
+
*
|
|
5
|
+
* @returns Streams for package-manager diagnostics, or the original terminal streams.
|
|
6
|
+
*/
|
|
7
|
+
export declare function upgradeOutputStreams(): {
|
|
8
|
+
stdout: Writable;
|
|
9
|
+
stderr: Writable;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Runs a global upgrade with terminal input and format-appropriate diagnostics.
|
|
13
|
+
*
|
|
14
|
+
* @param command - The package-manager executable.
|
|
15
|
+
* @param args - The install arguments.
|
|
16
|
+
*/
|
|
17
|
+
export declare function execUpgradeCommand(command: string, args: string[]): Promise<void>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { commandEventOutputMode } from '../command-events.js';
|
|
2
|
+
import { outputInfo } from '../output.js';
|
|
3
|
+
import { exec } from '../system.js';
|
|
4
|
+
import { Writable } from 'node:stream';
|
|
5
|
+
import { StringDecoder } from 'node:string_decoder';
|
|
6
|
+
/**
|
|
7
|
+
* Keeps package-manager output off the result channel in JSON mode.
|
|
8
|
+
*
|
|
9
|
+
* @returns Streams for package-manager diagnostics, or the original terminal streams.
|
|
10
|
+
*/
|
|
11
|
+
export function upgradeOutputStreams() {
|
|
12
|
+
if (commandEventOutputMode() !== 'json')
|
|
13
|
+
return { stdout: process.stdout, stderr: process.stderr };
|
|
14
|
+
return { stdout: diagnosticStream(), stderr: diagnosticStream() };
|
|
15
|
+
}
|
|
16
|
+
function diagnosticStream() {
|
|
17
|
+
const decoder = new StringDecoder('utf8');
|
|
18
|
+
return new Writable({
|
|
19
|
+
write(chunk, _encoding, callback) {
|
|
20
|
+
const message = decoder.write(chunk);
|
|
21
|
+
if (message)
|
|
22
|
+
outputInfo(message);
|
|
23
|
+
callback();
|
|
24
|
+
},
|
|
25
|
+
final(callback) {
|
|
26
|
+
const message = decoder.end();
|
|
27
|
+
if (message)
|
|
28
|
+
outputInfo(message);
|
|
29
|
+
callback();
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Runs a global upgrade with terminal input and format-appropriate diagnostics.
|
|
35
|
+
*
|
|
36
|
+
* @param command - The package-manager executable.
|
|
37
|
+
* @param args - The install arguments.
|
|
38
|
+
*/
|
|
39
|
+
export async function execUpgradeCommand(command, args) {
|
|
40
|
+
const streams = upgradeOutputStreams();
|
|
41
|
+
try {
|
|
42
|
+
await exec(command, args, streams.stdout === process.stdout ? { stdio: 'inherit' } : { stdin: 'inherit', ...streams });
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
if (streams.stdout !== process.stdout)
|
|
46
|
+
streams.stdout.end();
|
|
47
|
+
if (streams.stderr !== process.stderr)
|
|
48
|
+
streams.stderr.end();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../../../src/public/node/upgrade/output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAA;AACpC,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAA;AAEjD;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAClC,IAAI,sBA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AI,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM;YAAE,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA;IAC7D,CAAC;AACH,CAAC","sourcesContent":["import {commandEventOutputMode} from '../command-events.js'\nimport {outputInfo} from '../output.js'\nimport {exec} from '../system.js'\nimport {Writable} from 'node:stream'\nimport {StringDecoder} from 'node:string_decoder'\n\n/**\n * Keeps package-manager output off the result channel in JSON mode.\n *\n * @returns Streams for package-manager diagnostics, or the original terminal streams.\n */\nexport function upgradeOutputStreams(): {stdout: Writable; stderr: Writable} {\n if (commandEventOutputMode() !== 'json') return {stdout: process.stdout, stderr: process.stderr}\n\n return {stdout: diagnosticStream(), stderr: diagnosticStream()}\n}\n\nfunction diagnosticStream(): Writable {\n const decoder = new StringDecoder('utf8')\n return new Writable({\n write(chunk, _encoding, callback) {\n const message = decoder.write(chunk)\n if (message) outputInfo(message)\n callback()\n },\n final(callback) {\n const message = decoder.end()\n if (message) outputInfo(message)\n callback()\n },\n })\n}\n\n/**\n * Runs a global upgrade with terminal input and format-appropriate diagnostics.\n *\n * @param command - The package-manager executable.\n * @param args - The install arguments.\n */\nexport async function execUpgradeCommand(command: string, args: string[]): Promise<void> {\n const streams = upgradeOutputStreams()\n try {\n await exec(command, args, streams.stdout === process.stdout ? {stdio: 'inherit'} : {stdin: 'inherit', ...streams})\n } finally {\n if (streams.stdout !== process.stdout) streams.stdout.end()\n if (streams.stderr !== process.stderr) streams.stderr.end()\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type UpgradeResult } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Presents the upgrade result without changing progress or package-manager output.
|
|
4
|
+
*
|
|
5
|
+
* @param result - The completed upgrade outcome.
|
|
6
|
+
* @param format - The output format selected by the caller.
|
|
7
|
+
*/
|
|
8
|
+
export declare function presentUpgradeResult(result: UpgradeResult, format: 'json' | 'text'): void;
|