-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathrenderer.ts
117 lines (97 loc) · 4.45 KB
/
renderer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import path from 'path'
import chalk from 'chalk'
import {ICONS} from '../../helpers/formatting'
import {UploadStatus} from '../../helpers/upload'
import {ArchSlice, CompressedDsym, Dsym} from './interfaces'
import {pluralize} from './utils'
export const renderConfigurationError = (error: Error) => chalk.red(`${ICONS.FAILED} Configuration error: ${error}.\n`)
export const renderInvalidDsymWarning = (dSYMPath: string) =>
chalk.yellow(`${ICONS.WARNING} Invalid dSYM file, will be skipped: ${dSYMPath}\n`)
export const renderDSYMSlimmingFailure = (dSYM: Dsym, slice: ArchSlice) =>
chalk.yellow(`${ICONS.WARNING} Failed to export '${slice.arch}' arch (${slice.uuid}) from ${dSYM.bundlePath}\n`)
export const renderFailedUpload = (dSYM: CompressedDsym, errorMessage: string) => {
const dSYMPathBold = `[${chalk.bold.dim(dSYM.dsym.bundlePath)}]`
return chalk.red(`${ICONS.FAILED} Failed upload dSYM for ${dSYMPathBold}: ${errorMessage}\n`)
}
export const renderRetriedUpload = (dSYM: CompressedDsym, errorMessage: string, attempt: number) => {
const dSYMPathBold = `[${chalk.bold.dim(dSYM.dsym.bundlePath)}]`
return chalk.yellow(`[attempt ${attempt}] Retrying dSYM upload ${dSYMPathBold}: ${errorMessage}\n`)
}
export const renderSuccessfulCommand = (statuses: UploadStatus[], duration: number, dryRun: boolean) => {
const results = new Map<UploadStatus, number>()
statuses.forEach((status) => {
if (!results.has(status)) {
results.set(status, 0)
}
results.set(status, results.get(status)! + 1)
})
const output = ['', chalk.bold('Command summary:')]
if (results.get(UploadStatus.Failure)) {
output.push(chalk.red(`${ICONS.FAILED} Some dSYMS have not been uploaded correctly.`))
} else if (results.get(UploadStatus.Skipped)) {
output.push(chalk.yellow(`${ICONS.WARNING} Some dSYMs have been skipped.`))
} else if (results.get(UploadStatus.Success)) {
if (dryRun) {
output.push(
chalk.green(
`${ICONS.SUCCESS} [DRYRUN] Handled ${pluralize(
results.get(UploadStatus.Success)!,
'dSYM',
'dSYMs'
)} with success in ${duration} seconds.`
)
)
} else {
output.push(
chalk.green(
`${ICONS.SUCCESS} Uploaded ${pluralize(
results.get(UploadStatus.Success)!,
'dSYM',
'dSYMs'
)} in ${duration} seconds.`
)
)
}
} else {
output.push(chalk.yellow(`${ICONS.WARNING} No dSYMs detected. Did you specify the correct directory?`))
}
if (results.get(UploadStatus.Failure) || results.get(UploadStatus.Skipped)) {
output.push(`Details about the found ${pluralize(statuses.length, 'dSYM', 'dSYMs')}:`)
if (results.get(UploadStatus.Success)) {
output.push(` * ${pluralize(results.get(UploadStatus.Success)!, 'dSYM', 'dSYMs')} successfully uploaded`)
}
if (results.get(UploadStatus.Skipped)) {
output.push(
chalk.yellow(` * ${pluralize(results.get(UploadStatus.Skipped)!, 'dSYM was', 'dSYMs were')} skipped`)
)
}
if (results.get(UploadStatus.Failure)) {
output.push(chalk.red(` * ${pluralize(results.get(UploadStatus.Failure)!, 'dSYM', 'dSYMs')} failed to upload`))
}
}
return output.join('\n') + '\n'
}
export const renderCommandInfo = (basePath: string, poolLimit: number, dryRun: boolean) => {
let fullStr = ''
if (dryRun) {
fullStr += chalk.yellow(`${ICONS.WARNING} DRY-RUN MODE ENABLED. WILL NOT UPLOAD DSYMS\n`)
}
const startStr = chalk.green(`Starting upload with concurrency ${poolLimit}. \n`)
fullStr += startStr
const basePathStr = chalk.green(`Will look for dSYMs in ${basePath}\n`)
fullStr += basePathStr
fullStr += chalk.green(
`Once dSYMs upload is successful files will be processed and ready to use within the next 5 minutes.\n`
)
return fullStr
}
export const renderCommandDetail = (intermediateDirectory: string, uploadDirectory: string) =>
`Will use temporary intermediate directory: ${intermediateDirectory}\n` +
`Will use temporary upload directory: ${uploadDirectory}\n`
export const renderUpload = (dSYM: CompressedDsym): string => {
const archiveName = path.basename(dSYM.archivePath)
const objectName = dSYM.dsym.slices.map((slice) => path.basename(slice.objectPath))[0]
const archs = dSYM.dsym.slices.map((slice) => slice.arch).join()
const uuids = dSYM.dsym.slices.map((slice) => slice.uuid).join()
return `Uploading ${archiveName} (${objectName}, arch: ${archs}, UUID: ${uuids})\n`
}