( app: App, descriptors: AssetDescriptor[], )
| 150 | } |
| 151 | |
| 152 | async function encodeAssets( |
| 153 | app: App, |
| 154 | descriptors: AssetDescriptor[], |
| 155 | ): Promise<EncodedAssets> { |
| 156 | const encodedAssets: QuickAddPackageAsset[] = []; |
| 157 | const missingAssets: MissingAsset[] = []; |
| 158 | |
| 159 | for (const { path, kind } of descriptors) { |
| 160 | try { |
| 161 | const exists = await app.vault.adapter.exists(path); |
| 162 | if (!exists) { |
| 163 | missingAssets.push({ path, kind }); |
| 164 | log.logWarning(`QuickAdd export skipped missing ${kind}: ${path}`); |
| 165 | continue; |
| 166 | } |
| 167 | |
| 168 | const content = await app.vault.adapter.read(path); |
| 169 | |
| 170 | encodedAssets.push({ |
| 171 | kind, |
| 172 | originalPath: path, |
| 173 | contentEncoding: "base64", |
| 174 | content: encodeToBase64(content), |
| 175 | }); |
| 176 | } catch (error) { |
| 177 | missingAssets.push({ path, kind }); |
| 178 | log.logWarning( |
| 179 | `QuickAdd export failed to read ${kind} '${path}': ${ |
| 180 | (error as Error)?.message ?? error |
| 181 | }`, |
| 182 | ); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | return { encodedAssets, missingAssets }; |
| 187 | } |
| 188 | |
| 189 | function buildSecretOptionNamesByPath( |
| 190 | assets: QuickAddPackageAsset[], |
no test coverage detected