Review feedback.
Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
This commit is contained in:
committed by
Eric Peterson
parent
1bada775a9
commit
693db1da54
+1
-1
@@ -113,7 +113,7 @@ techdocs:
|
||||
publisher:
|
||||
type: 'local' # Alternatives - 'googleGcs' or 'awsS3' or 'azureBlobStorage' or 'openStackSwift'. Read documentation for using alternatives.
|
||||
cache:
|
||||
ttl: 60000 # 1 minute cache for demonstration purposes. You may wish to set this higher in production.
|
||||
ttl: 3600000 # 1 hour cache for demonstration purposes. You may wish to set this higher in production.
|
||||
sentry:
|
||||
organization: my-company
|
||||
|
||||
|
||||
@@ -98,7 +98,10 @@ export class LocalPublish implements PublisherBase {
|
||||
};
|
||||
}
|
||||
|
||||
publish({ entity, directory }: PublishRequest): Promise<PublishResponse> {
|
||||
async publish({
|
||||
entity,
|
||||
directory,
|
||||
}: PublishRequest): Promise<PublishResponse> {
|
||||
const entityNamespace = entity.metadata.namespace ?? 'default';
|
||||
|
||||
const publishDir = this.staticEntityPathJoin(
|
||||
@@ -112,32 +115,26 @@ export class LocalPublish implements PublisherBase {
|
||||
fs.mkdirSync(publishDir, { recursive: true });
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.copy(directory, publishDir, async err => {
|
||||
if (err) {
|
||||
this.logger.debug(
|
||||
`Failed to copy docs from ${directory} to ${publishDir}`,
|
||||
);
|
||||
reject(err);
|
||||
}
|
||||
this.logger.info(`Published site stored at ${publishDir}`);
|
||||
try {
|
||||
await fs.copy(directory, publishDir);
|
||||
this.logger.info(`Published site stored at ${publishDir}`);
|
||||
} catch (error) {
|
||||
this.logger.debug(
|
||||
`Failed to copy docs from ${directory} to ${publishDir}`,
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
|
||||
try {
|
||||
const techdocsApiUrl = await this.discovery.getBaseUrl('techdocs');
|
||||
const objects = (await getFileTreeRecursively(publishDir)).map(
|
||||
abs => {
|
||||
return abs.split(`${staticDocsDir}/`)[1];
|
||||
},
|
||||
);
|
||||
resolve({
|
||||
remoteUrl: `${techdocsApiUrl}/static/docs/${entity.metadata.name}`,
|
||||
objects,
|
||||
});
|
||||
} catch (reason) {
|
||||
reject(reason);
|
||||
}
|
||||
});
|
||||
// Generate publish response.
|
||||
const techdocsApiUrl = await this.discovery.getBaseUrl('techdocs');
|
||||
const objects = (await getFileTreeRecursively(publishDir)).map(abs => {
|
||||
return abs.split(`${staticDocsDir}/`)[1];
|
||||
});
|
||||
|
||||
return {
|
||||
remoteUrl: `${techdocsApiUrl}/static/docs/${entity.metadata.name}`,
|
||||
objects,
|
||||
};
|
||||
}
|
||||
|
||||
async fetchTechDocsMetadata(
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ export const createCacheMiddleware = ({
|
||||
};
|
||||
|
||||
// When a socket is closed, if there were no errors and the data written
|
||||
// over the socket should be cached, cache it as a base64-encoded string!
|
||||
// over the socket should be cached, cache it!
|
||||
socket.on('close', hadError => {
|
||||
if (writeToCache && !hadError) {
|
||||
cache.set(reqPath, Buffer.concat(chunks));
|
||||
|
||||
Reference in New Issue
Block a user