techdocs-common: Unify response type of Local and googleGcs publisher
This commit is contained in:
@@ -75,6 +75,6 @@ describe('GoogleGCSPublish', () => {
|
||||
const entity = createMockEntity();
|
||||
return expect(
|
||||
publisher.publish({ entity, directory: '/path/to/generatedDirectory' }),
|
||||
).resolves.toStrictEqual({});
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -93,7 +93,7 @@ export class GoogleGCSPublish implements PublisherBase {
|
||||
* Upload all the files from the generated `directory` to the GCS bucket.
|
||||
* Directory structure used in the bucket is - entityNamespace/entityKind/entityName/index.html
|
||||
*/
|
||||
publish({ entity, directory }: PublishRequest): Promise<{}> {
|
||||
publish({ entity, directory }: PublishRequest): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
// Path of all files to upload, relative to the root of the source directory
|
||||
// e.g. ['index.html', 'sub-page/index.html', 'assets/images/favicon.png']
|
||||
@@ -140,7 +140,7 @@ export class GoogleGCSPublish implements PublisherBase {
|
||||
this.logger.info(
|
||||
`Successfully uploaded all the generated files for Entity ${entityRootDir}. Total number of files: ${allFilesToUpload.length}`,
|
||||
);
|
||||
resolve({});
|
||||
resolve(undefined);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,10 +23,7 @@ import {
|
||||
PluginEndpointDiscovery,
|
||||
} from '@backstage/backend-common';
|
||||
import { Config } from '@backstage/config';
|
||||
import { PublisherBase, PublishRequest } from './types';
|
||||
|
||||
/* `remoteUrl` is the URL which serves files from the local publisher's static directory. */
|
||||
export type LocalPublishReturn = Promise<{ remoteUrl: string }>;
|
||||
import { PublisherBase, PublishRequest, PublishResponse } from './types';
|
||||
|
||||
const staticDocsDir = resolvePackagePath(
|
||||
'@backstage/plugin-techdocs-backend',
|
||||
@@ -52,7 +49,7 @@ export class LocalPublish implements PublisherBase {
|
||||
this.discovery = discovery;
|
||||
}
|
||||
|
||||
publish({ entity, directory }: PublishRequest): LocalPublishReturn {
|
||||
publish({ entity, directory }: PublishRequest): Promise<PublishResponse> {
|
||||
const entityNamespace = entity.metadata.namespace ?? 'default';
|
||||
|
||||
const publishDir = resolvePackagePath(
|
||||
|
||||
@@ -27,7 +27,10 @@ export type PublishRequest = {
|
||||
directory: string;
|
||||
};
|
||||
|
||||
export type PublishResponse = {};
|
||||
/* `remoteUrl` is the URL which serves files from the local publisher's static directory. */
|
||||
export type PublishResponse = {
|
||||
remoteUrl?: string;
|
||||
} | void;
|
||||
|
||||
/**
|
||||
* Base class for a TechDocs publisher (e.g. Local, Google GCS Bucket, AWS S3, etc.)
|
||||
|
||||
Reference in New Issue
Block a user