MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / build

Function build

packages/sitemap/src/build.ts:14–55  ·  view source on GitHub ↗
(
  uploadFile: (args: {
    Key: string;
    Body: any;
    CacheControl?: string;
  }) => Promise<any>,
  logger: Logger
)

Source from the content-addressed store, hash-verified

12import { Logger } from '@linen/types';
13
14export 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}

Callers 2

taskFunction · 0.90
run-local.tsFile · 0.90

Calls 7

getAccountsAndChannelsFunction · 0.90
getThreadsFunction · 0.90
buildCustomDomainSitemapFunction · 0.90
buildRobotsFunction · 0.90
buildLinenSitemapFunction · 0.90
uploadDirFunction · 0.90
logMethod · 0.65

Tested by

no test coverage detected