( pkg: QuickAddPackage, )
| 807 | } |
| 808 | |
| 809 | function buildSecretOptionNamesByPath( |
| 810 | pkg: QuickAddPackage, |
| 811 | ): Map<string, ReadonlySet<string> | null> { |
| 812 | const secretOptionNamesByPath = new Map<string, ReadonlySet<string> | null>(); |
| 813 | |
| 814 | for (const asset of pkg.assets) { |
| 815 | if (asset.kind !== "user-script") continue; |
| 816 | |
| 817 | try { |
| 818 | const detection = detectUserScriptSecretOptions( |
| 819 | decodeFromBase64(asset.content), |
| 820 | asset.originalPath, |
| 821 | ); |
| 822 | secretOptionNamesByPath.set( |
| 823 | asset.originalPath, |
| 824 | detection.foundSecretOptions && detection.names.size === 0 |
| 825 | ? null |
| 826 | : detection.names, |
| 827 | ); |
| 828 | } catch (error) { |
| 829 | log.logWarning( |
| 830 | `QuickAdd import could not inspect user-script settings '${asset.originalPath}': ${ |
| 831 | (error as Error)?.message ?? error |
| 832 | }`, |
| 833 | ); |
| 834 | } |
| 835 | } |
| 836 | |
| 837 | return secretOptionNamesByPath; |
| 838 | } |
| 839 | |
| 840 | async function assetExists(app: App, path: string): Promise<boolean> { |
| 841 | try { |
no test coverage detected