| 101 | export const defaultMode = 'warn:summary' |
| 102 | |
| 103 | export const printSummary = async () => { |
| 104 | if (!bufferedDeprecations.length) { |
| 105 | try { |
| 106 | await fsp.unlink(healthStatusFilename) |
| 107 | } catch { |
| 108 | // ignore |
| 109 | } |
| 110 | return |
| 111 | } |
| 112 | |
| 113 | try { |
| 114 | const healthStatus = [] |
| 115 | |
| 116 | deprecationLogger.warning() |
| 117 | |
| 118 | if (bufferedDeprecations.length === 1) { |
| 119 | healthStatus.push('1 deprecation triggered in the last command:', '') |
| 120 | deprecationLogger.warning( |
| 121 | style.aside( |
| 122 | "1 deprecation found: run 'serverless doctor' for more details", |
| 123 | ), |
| 124 | ) |
| 125 | } else { |
| 126 | healthStatus.push( |
| 127 | `${bufferedDeprecations.length} deprecations triggered in the last command:`, |
| 128 | '', |
| 129 | ) |
| 130 | deprecationLogger.warning( |
| 131 | style.aside( |
| 132 | `${bufferedDeprecations.length} deprecations found: run 'serverless doctor' for more details`, |
| 133 | ), |
| 134 | ) |
| 135 | } |
| 136 | for (const { code, message } of bufferedDeprecations) { |
| 137 | healthStatus.push(message) |
| 138 | if (!code.startsWith('EXT_')) { |
| 139 | healthStatus.push( |
| 140 | style.aside( |
| 141 | `More info: https://serverless.com/framework/docs/deprecations/#${code}`, |
| 142 | ), |
| 143 | ) |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | const tmpDir = await fsp.mkdtemp('sls-ld') |
| 148 | |
| 149 | const tmpHealthStatusFilename = path.resolve(tmpDir, 'health-status') |
| 150 | await Promise.all([ |
| 151 | fse.ensureDir(path.dirname(healthStatusFilename)), |
| 152 | fsp.writeFile(tmpHealthStatusFilename, healthStatus.join('\n')), |
| 153 | ]) |
| 154 | try { |
| 155 | await safeMoveFile(tmpHealthStatusFilename, healthStatusFilename) |
| 156 | } catch (error) { |
| 157 | if (error.code === 'EACCES') { |
| 158 | log.error( |
| 159 | 'Cannot store information on approached deprecation. Please ensure process has write access to the ~/.serverless directory', |
| 160 | ) |