Skip to content

Commit

Permalink
Merge pull request #10224 from hicommonwealth/release/v1.7.5-x
Browse files Browse the repository at this point in the history
Release/v1.7.5 x
  • Loading branch information
ilijabojanovic authored Dec 11, 2024
2 parents d78fc70 + 9ae5d21 commit 5bfb2d5
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 14 deletions.
4 changes: 2 additions & 2 deletions libs/adapters/src/blobStorage/s3.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CompleteMultipartUploadCommandOutput, S3 } from '@aws-sdk/client-s3';
import { BlobBucket, type BlobStorage } from '@hicommonwealth/core';
import { S3_ASSET_BUCKET_CDN } from '@hicommonwealth/shared';
import { PRODUCTION_DOMAIN, S3_ASSET_BUCKET_CDN } from '@hicommonwealth/shared';
import { config } from '../config';
import { exists_S3sdk, getSignedUrl_S3sdk, upload_S3sdk } from './util';

Expand All @@ -14,7 +14,7 @@ const s3Buckets: Partial<Record<BlobBucket, string>> =
: {
assets: S3_ASSET_BUCKET_CDN,
archives: 'outbox-event-stream-archive',
sitemap: 'sitemap.commonwealth.im',
sitemap: `sitemap.${PRODUCTION_DOMAIN}`,
};

function formatS3Url(
Expand Down
6 changes: 6 additions & 0 deletions libs/shared/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export const DEFAULT_NAME = 'Anonymous';

export const MAX_RECIPIENTS_PER_WORKFLOW_TRIGGER = 1_000;

export const PRODUCTION_DOMAIN = 'common.xyz';

export const BLOG_SUBDOMAIN = `blog.${PRODUCTION_DOMAIN}`;

export const DOCS_SUBDOMAIN = `docs.${PRODUCTION_DOMAIN}`;

export const S3_RAW_ASSET_BUCKET_DOMAIN =
's3.us-east-1.amazonaws.com/assets.commonwealth.im';
export const S3_ASSET_BUCKET_CDN = 'assets.commonwealth.im';
Expand Down
9 changes: 7 additions & 2 deletions libs/sitemaps/src/createSitemapGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { blobStorage, logger } from '@hicommonwealth/core';
import { Paginator } from './createDatabasePaginator';
import { createSitemap } from './createSitemap';
import { createSitemapIndex } from './createSitemapIndex';
import { rewriteURL } from './rewriteURL';

const log = logger(import.meta);

Expand All @@ -20,6 +21,7 @@ export interface SitemapGenerator {

export function createSitemapGenerator(
paginators: ReadonlyArray<Paginator>,
hostname: string | undefined,
): SitemapGenerator {
async function exec(): Promise<SitemapManifest> {
let idx = 0;
Expand All @@ -44,8 +46,11 @@ export function createSitemapGenerator(
content: sitemap,
contentType: 'text/xml; charset=utf-8',
});
log.info(`Wrote sitemap: ${sitemapPath} to location ${res.url}`);
children.push({ location: res.url });

const url = rewriteURL(res.url, hostname);

log.info(`Wrote sitemap: ${sitemapPath} to location ${url}`);
children.push({ location: url });
}
}

Expand Down
12 changes: 12 additions & 0 deletions libs/sitemaps/src/rewriteURL.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* AWS returns invalid URLs not the domain masked URL.
*/
export function rewriteURL(url: string, hostname: string | undefined): string {
if (!hostname) {
return url;
}

const u = new URL(url);
u.hostname = hostname;
return u.toString();
}
8 changes: 4 additions & 4 deletions libs/sitemaps/test/integration/createSitemapGenerator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ describe('createSitemapGenerator', { timeout: 10_000 }, function () {

test('basic', async () => {
const paginator = createDatabasePaginatorDefault(50);
const sitemapGenerator = createSitemapGenerator([
paginator.threads,
paginator.profiles,
]);
const sitemapGenerator = createSitemapGenerator(
[paginator.threads, paginator.profiles],
undefined,
);

const written = await sitemapGenerator.exec();
expect(inMemoryBlobs.size).to.equal(2);
Expand Down
2 changes: 1 addition & 1 deletion packages/commonwealth/client/public/robots.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
User-agent: *
Disallow: /profile

Sitemap: https://sitemap.commonwealth.im/sitemap-index.xml
Sitemap: https://sitemap.common.xyz/sitemap-index.xml

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ APP_ENV=production
KNOCK_PUBLIC_API_KEY=pk_ynCCqD_rlxXTO0TvBCYUKYV5BSG5-vHoy451WGDHW5w
KNOCK_IN_APP_FEED_ID=fc6e68e5-b7b9-49c1-8fab-6dd7e3510ffb
NODE_ENV=production
SERVER_URL=https://commonwealth.im
SERVER_URL=https://common.xyz
MAGIC_PUBLISHABLE_KEY=pk_live_B0604AA1B8EEFDB4
DISCORD_CLIENT_ID=1133050809412763719
SNAPSHOT_HUB_URL=https://hub.snapshot.org
Expand Down
11 changes: 7 additions & 4 deletions packages/commonwealth/scripts/sitemap-runner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { HotShotsStats, S3BlobStorage } from '@hicommonwealth/adapters';
import { blobStorage, dispose, logger, stats } from '@hicommonwealth/core';
import { PRODUCTION_DOMAIN } from '@hicommonwealth/shared';
import {
createDatabasePaginatorDefault,
createSitemapGenerator,
Expand Down Expand Up @@ -33,10 +34,12 @@ async function doExec() {
log.info('Creating paginator... ');
const paginator = createDatabasePaginatorDefault();

const { index } = await createSitemapGenerator([
paginator.threads,
paginator.profiles,
]).exec();
const hostname = `sitemap.${PRODUCTION_DOMAIN}`;

const { index } = await createSitemapGenerator(
[paginator.threads, paginator.profiles],
hostname,
).exec();

log.info('Sitemap written to: ' + index.location);
}
Expand Down

0 comments on commit 5bfb2d5

Please sign in to comment.