()
| 135 | let currentVersion = ""; |
| 136 | try { currentVersion = fs.readFileSync(versionFile, "utf8").trim(); } catch { |
| 137 | console.debug("[quote] version file read failed"); |
| 138 | } |
| 139 | if (currentVersion !== QUOTE_PLUGIN_VERSION) return false; |
| 140 | if (QUOTE_DEP_FILES.some((rel) => !fs.existsSync(path.join(quoteDir, rel)))) return false; |
| 141 | if (QUOTE_ASSET_FILES.some((rel) => !fs.existsSync(path.join(QUOTE_ASSETS_DIR, rel)))) return false; |
| 142 | if (QUOTE_FONT_FILES.some((font) => !fs.existsSync(path.join(QUOTE_ASSETS_DIR, font.name)))) return false; |
| 143 | return true; |
| 144 | } |
| 145 | |
| 146 | async function ensureQuoteAssets(): Promise<void> { |
| 147 | const quoteDir = path.join(quotePluginDir(), "quote"); |
| 148 | const versionFile = path.join(quoteDir, ".version"); |
| 149 | let currentVersion = ""; |
| 150 | try { currentVersion = fs.readFileSync(versionFile, "utf8").trim(); } catch { |
| 151 | console.debug("[quote] version file read failed"); |
| 152 | } |
| 153 | |
| 154 | if (currentVersion !== QUOTE_PLUGIN_VERSION) { |
| 155 | const missingVendor = QUOTE_DEP_FILES.filter((rel) => !fs.existsSync(path.join(quoteDir, rel))); |
| 156 | if (missingVendor.length > 0) { |
| 157 | console.warn("quote loader installing missing vendor", { from: currentVersion || undefined, to: QUOTE_PLUGIN_VERSION, count: missingVendor.length }); |
| 158 | for (const rel of missingVendor) { |
| 159 | await downloadFileIfMissingOrChanged(`${QUOTE_BASE_URL}/${rel}`, path.join(quoteDir, rel)); |
| 160 | } |
| 161 | } |
| 162 | fs.mkdirSync(quoteDir, { recursive: true }); |
| 163 | fs.writeFileSync(versionFile, QUOTE_PLUGIN_VERSION); |
| 164 | } |
| 165 | |
| 166 | for (const rel of QUOTE_ASSET_FILES) { |
| 167 | const filePath = path.join(QUOTE_ASSETS_DIR, rel); |
| 168 | if (!fs.existsSync(filePath)) { |
| 169 | console.warn("quote loader downloading asset", { rel }); |
| 170 | await downloadFileIfMissingOrChanged(`${QUOTE_ASSETS_BASE_URL}/${rel}`, filePath); |
| 171 | } |
| 172 | } |
| 173 |
no test coverage detected