(
uploadFile: (args: {
Key: string;
Body: any;
CacheControl?: string;
}) => Promise<any>,
logger: Logger
)
| 12 | import { Logger } from '@linen/types'; |
| 13 | |
| 14 | export async function build( |
| 15 | uploadFile: (args: { |
| 16 | Key: string; |
| 17 | Body: any; |
| 18 | CacheControl?: string; |
| 19 | }) => Promise<any>, |
| 20 | logger: Logger |
| 21 | ) { |
| 22 | const { |
| 23 | channels, |
| 24 | accountsPremium, |
| 25 | accountsFree, |
| 26 | }: { |
| 27 | channels: Record<string, ChannelType>; |
| 28 | accountsPremium: Record<string, AccountType>; |
| 29 | accountsFree: Record<string, AccountType>; |
| 30 | } = await getAccountsAndChannels(logger); |
| 31 | |
| 32 | const { |
| 33 | sitemapPremium, |
| 34 | sitemapFree, |
| 35 | }: { sitemapPremium: Record<string, UrlType[]>; sitemapFree: UrlType[] } = |
| 36 | await getThreads(channels, logger); |
| 37 | |
| 38 | const workDir = resolve( |
| 39 | process.env.RUN_LOCAL ? './sitemap' : os.tmpdir(), |
| 40 | Date.now().toString() |
| 41 | ); |
| 42 | await fs.mkdir(workDir, { recursive: true }); |
| 43 | |
| 44 | for (let [accountId, threads] of Object.entries(sitemapPremium)) { |
| 45 | const account = accountsPremium[accountId]; |
| 46 | await buildCustomDomainSitemap(workDir, account, threads, logger); |
| 47 | await buildRobots(account.customDomain, workDir).catch(logger.error); |
| 48 | } |
| 49 | |
| 50 | await buildLinenSitemap(workDir, sitemapFree, accountsFree, logger); |
| 51 | await buildRobots(linenDomain, workDir).catch(logger.error); |
| 52 | |
| 53 | const result = await uploadDir(uploadFile, resolve(workDir)); |
| 54 | logger.log({ 'files uploaded': result.length }); |
| 55 | } |
no test coverage detected