MCPcopy Create free account
hub / github.com/TanStack/cli / createUIEnvironment

Function createUIEnvironment

packages/cli/src/ui-environment.ts:16–91  ·  view source on GitHub ↗
(
  appName: string,
  silent: boolean,
  getTelemetry?: () => TelemetryClient | undefined,
)

Source from the content-addressed store, hash-verified

14import type { TelemetryClient } from './telemetry.js'
15
16export function createUIEnvironment(
17 appName: string,
18 silent: boolean,
19 getTelemetry?: () => TelemetryClient | undefined,
20): Environment {
21 const defaultEnvironment = createDefaultEnvironment()
22
23 let newEnvironment = {
24 ...defaultEnvironment,
25 appName,
26 }
27
28 if (!silent) {
29 newEnvironment = {
30 ...newEnvironment,
31 intro: (message: string) => {
32 intro(message)
33 },
34 outro: (message: string) => {
35 outro(message)
36 },
37 info: (title?: string, message?: string) => {
38 log.info(
39 `${title ? chalk.red(title) : ''}${message ? '\n' + chalk.green(message) : ''}`,
40 )
41 },
42 error: (title?: string, message?: string) => {
43 log.error(
44 `${title ? `${title}: ` : ''}${message ? '\n' + message : ''}`,
45 )
46 },
47 warn: (title?: string, message?: string) => {
48 log.warn(`${title ? `${title}: ` : ''}${message ? '\n' + message : ''}`)
49 },
50 confirm: async (message: string) => {
51 const shouldContinue = await confirm({
52 message,
53 })
54 if (isCancel(shouldContinue)) {
55 cancel('Operation cancelled.')
56 process.exit(0)
57 }
58 return shouldContinue
59 },
60 spinner: () => {
61 const s = spinner()
62 return {
63 start: (message: string) => {
64 s.start(message)
65 },
66 stop: (message: string) => {
67 s.stop(message)
68 },
69 }
70 },
71 startStep: (info: StatusEvent) => {
72 getTelemetry?.()?.startStep(info)
73 },

Callers 5

rebuildMethod · 0.85
cliFunction · 0.85
startDevWatchModeFunction · 0.85
telemetry.test.tsFile · 0.85

Calls 8

createDefaultEnvironmentFunction · 0.90
errorMethod · 0.80
warnMethod · 0.80
stopMethod · 0.80
startStepMethod · 0.80
finishStepMethod · 0.80
infoMethod · 0.65
startMethod · 0.65

Tested by

no test coverage detected