diff --git a/.changeset/odd-avocados-buy.md b/.changeset/odd-avocados-buy.md new file mode 100644 index 0000000000..9e71c19fc0 --- /dev/null +++ b/.changeset/odd-avocados-buy.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-confluence-to-markdown': patch +--- + +Use `fetchContents` directly instead of a `fetchPlainAction` diff --git a/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.test.ts b/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.test.ts index b3e2925265..4e4f3091f1 100644 --- a/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.test.ts +++ b/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.test.ts @@ -157,7 +157,7 @@ describe('confluence:transform:markdown', () => { expect(logger.info).toHaveBeenCalledWith( `Fetching the mkdocs.yml catalog from https://notreal.github.com/space/backstage/mkdocs.yml`, ); - expect(logger.info).toHaveBeenCalledTimes(6); + expect(logger.info).toHaveBeenCalledTimes(5); expect(createWriteStream).toHaveBeenCalledTimes(1); expect(readFile).toHaveBeenCalledTimes(1); expect(writeFile).toHaveBeenCalledTimes(1); @@ -204,7 +204,7 @@ describe('confluence:transform:markdown', () => { expect(logger.info).toHaveBeenCalledWith( `Fetching the mkdocs.yml catalog from https://notreal.github.com/space/backstage/mkdocs.yml`, ); - expect(logger.info).toHaveBeenCalledTimes(6); + expect(logger.info).toHaveBeenCalledTimes(5); expect(createWriteStream).not.toHaveBeenCalled(); expect(readFile).toHaveBeenCalledTimes(1); diff --git a/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.ts b/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.ts index 9b666fd99e..428f392555 100644 --- a/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.ts +++ b/plugins/scaffolder-backend-module-confluence-to-markdown/src/actions/confluence/confluenceToMarkdown.ts @@ -16,7 +16,7 @@ import { Config } from '@backstage/config'; import { UrlReader } from '@backstage/backend-common'; import { ScmIntegrations } from '@backstage/integration'; -import { createFetchPlainAction } from '@backstage/plugin-scaffolder-backend'; +import { fetchContents } from '@backstage/plugin-scaffolder-backend'; import { createTemplateAction } from '@backstage/plugin-scaffolder-node'; import { InputError, ConflictError } from '@backstage/errors'; import { NodeHtmlMarkdown } from 'node-html-markdown'; @@ -41,7 +41,6 @@ export const createConfluenceToMarkdownAction = (options: { config: Config; }) => { const { config, reader, integrations } = options; - const fetchPlainAction = createFetchPlainAction({ reader, integrations }); type Obj = { [key: string]: string; }; @@ -82,18 +81,18 @@ export const createConfluenceToMarkdownAction = (options: { parsedRepoUrl.filepath.lastIndexOf('/') + 1, ); const dirPath = ctx.workspacePath; + const repoFileDir = `${dirPath}/${parsedRepoUrl.filepath}`; let productArray: string[][] = []; ctx.logger.info(`Fetching the mkdocs.yml catalog from ${repoUrl}`); // This grabs the files from Github - const repoFileDir = `${dirPath}/${parsedRepoUrl.filepath}`; - await fetchPlainAction.handler({ - ...ctx, - input: { - url: `https://${parsedRepoUrl.resource}/${parsedRepoUrl.owner}/${parsedRepoUrl.name}`, - targetPath: dirPath, - }, + await fetchContents({ + reader, + integrations, + baseUrl: ctx.templateInfo?.baseUrl, + fetchUrl: `https://${parsedRepoUrl.resource}/${parsedRepoUrl.owner}/${parsedRepoUrl.name}`, + outputPath: ctx.workspacePath, }); for (const url of confluenceUrls) {