@backstage/plugin-scaffolder-backend-module-confluence-to-markdown 0.0.0-nightly-20230325022054
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +118 -0
- package/dist/index.cjs.js +209 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/package.json +49 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @backstage/plugin-scaffolder-backend-module-confluence-to-markdown
|
|
2
|
+
|
|
3
|
+
## 0.0.0-nightly-20230325022054
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1b49a18bf8d: Created `confluence:transform:markdown` action for converting confluence docs to Markdown.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/plugin-scaffolder-backend@0.0.0-nightly-20230325022054
|
|
13
|
+
- @backstage/plugin-scaffolder-node@0.0.0-nightly-20230325022054
|
|
14
|
+
- @backstage/backend-common@0.0.0-nightly-20230325022054
|
|
15
|
+
- @backstage/config@1.0.7
|
|
16
|
+
- @backstage/errors@1.1.5
|
|
17
|
+
- @backstage/integration@1.4.3
|
|
18
|
+
- @backstage/types@1.0.2
|
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# @backstage/plugin-scaffolder-backend-module-confluence-to-markdown
|
|
2
|
+
|
|
3
|
+
Welcome to the `confluence:transform:markdown` action for the `scaffolder-backend`.
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
You need to configure the action in your backend:
|
|
8
|
+
|
|
9
|
+
## From your Backstage root directory
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# From your Backstage root directory
|
|
13
|
+
yarn add --cwd packages/backend @backstage/plugin-scaffolder-backend-module-confluence-to-markdown
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Configure the action:
|
|
17
|
+
(you can check the [docs](https://backstage.io/docs/features/software-templates/writing-custom-actions#registering-custom-actions) to see all options):
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
// packages/backend/src/plugins/scaffolder.ts
|
|
21
|
+
|
|
22
|
+
import { createBuiltinActions } from '@backstage/plugin-scaffolder-backend';
|
|
23
|
+
import { ScmIntegrations } from '@backstage/integration';
|
|
24
|
+
import { createConfluenceToMarkdownAction } from '@backstage/plugin-scaffolder-backend-module-confluence-to-markdown';
|
|
25
|
+
|
|
26
|
+
export default async function createPlugin(
|
|
27
|
+
env: PluginEnvironment,
|
|
28
|
+
): Promise<Router> {
|
|
29
|
+
const catalogClient = new CatalogClient({ discoveryApi: env.discovery });
|
|
30
|
+
const integrations = ScmIntegrations.fromConfig(env.config);
|
|
31
|
+
|
|
32
|
+
const builtInActions = createBuiltinActions({
|
|
33
|
+
integrations,
|
|
34
|
+
catalogClient,
|
|
35
|
+
config: env.config,
|
|
36
|
+
reader: env.reader,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const actions = [
|
|
40
|
+
...builtInActions,
|
|
41
|
+
createConfluenceToMarkdownAction({
|
|
42
|
+
integrations,
|
|
43
|
+
config: env.config,
|
|
44
|
+
reader: env.reader,
|
|
45
|
+
}),
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
return createRouter({
|
|
49
|
+
actions,
|
|
50
|
+
catalogClient: catalogClient,
|
|
51
|
+
logger: env.logger,
|
|
52
|
+
config: env.config,
|
|
53
|
+
database: env.database,
|
|
54
|
+
reader: env.reader,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
You will also need an access token for authorization with `Read` permissions. You can create a Personal Access Token (PAT) in confluence and add the PAT to your `app-config.yaml`
|
|
60
|
+
|
|
61
|
+
```yaml
|
|
62
|
+
confluence:
|
|
63
|
+
baseUrl: ${CONFLUENCE_BASE_URL}
|
|
64
|
+
token: ${CONFLUENCE_TOKEN}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
After that you can use the action in your template:
|
|
68
|
+
|
|
69
|
+
```yaml
|
|
70
|
+
apiVersion: scaffolder.backstage.io/v1beta3
|
|
71
|
+
kind: Template
|
|
72
|
+
metadata:
|
|
73
|
+
name: confluence-to-markdown
|
|
74
|
+
title: Confluence to Markdown
|
|
75
|
+
description: This template converts a single confluence document to Markdown for Techdocs and adds it to a given GitHub repo.
|
|
76
|
+
tags:
|
|
77
|
+
- do-not-use
|
|
78
|
+
- poc
|
|
79
|
+
spec:
|
|
80
|
+
owner: <YOUR_EMAIL>
|
|
81
|
+
type: service
|
|
82
|
+
parameters:
|
|
83
|
+
- title: Confluence and Github Repo Information
|
|
84
|
+
properties:
|
|
85
|
+
confluenceUrls:
|
|
86
|
+
type: array
|
|
87
|
+
description: Urls for confluence doc to be converted to markdown. In format <CONFLUENCE_BASE_URL>/display/<SPACEKEY>/<PAGE+TITLE>
|
|
88
|
+
items:
|
|
89
|
+
type: string
|
|
90
|
+
default: confluence url
|
|
91
|
+
ui:options:
|
|
92
|
+
addable: true
|
|
93
|
+
minItems: 1
|
|
94
|
+
maxItems: 5
|
|
95
|
+
repoUrl:
|
|
96
|
+
type: string
|
|
97
|
+
title: GitHub URL mkdocs.yaml link
|
|
98
|
+
description: The GitHub repo URL to your mkdocs.yaml file. Example <https://github.com/blob/master/mkdocs.yml>
|
|
99
|
+
steps:
|
|
100
|
+
- id: create-docs
|
|
101
|
+
name: Get markdown file created and update markdown.yaml file
|
|
102
|
+
action: confluence:transform:markdown
|
|
103
|
+
input:
|
|
104
|
+
confluenceUrls: ${{ parameters.confluenceUrls }}
|
|
105
|
+
repoUrl: ${{ parameters.repoUrl }}
|
|
106
|
+
- id: publish
|
|
107
|
+
name: Publish PR to GitHub
|
|
108
|
+
action: publish:github:pull-request
|
|
109
|
+
input:
|
|
110
|
+
repoUrl: <GITHUB_BASE_URL>?repo=${{ steps['create-docs'].output.repo }}&owner=${{ steps['create-docs'].output.owner }}
|
|
111
|
+
branchName: confluence-to-markdown
|
|
112
|
+
title: Confluence to Markdown
|
|
113
|
+
description: PR for converting confluence page to mkdocs
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Replace `<GITHUB_BASE_URL>` with your GitHub URL without `https://`.
|
|
117
|
+
|
|
118
|
+
You can find a list of all registered actions including their parameters at the /create/actions route in your Backstage application.
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var pluginScaffolderBackend = require('@backstage/plugin-scaffolder-backend');
|
|
6
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
7
|
+
var errors = require('@backstage/errors');
|
|
8
|
+
var nodeHtmlMarkdown = require('node-html-markdown');
|
|
9
|
+
var fs = require('fs-extra');
|
|
10
|
+
var parseGitUrl = require('git-url-parse');
|
|
11
|
+
var YAML = require('yaml');
|
|
12
|
+
var fetch = require('node-fetch');
|
|
13
|
+
|
|
14
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
+
|
|
16
|
+
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
17
|
+
var parseGitUrl__default = /*#__PURE__*/_interopDefaultLegacy(parseGitUrl);
|
|
18
|
+
var YAML__default = /*#__PURE__*/_interopDefaultLegacy(YAML);
|
|
19
|
+
var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
|
|
20
|
+
|
|
21
|
+
const readFileAsString = async (fileDir) => {
|
|
22
|
+
const content = await fs__default["default"].readFile(fileDir, "utf-8");
|
|
23
|
+
return content.toString();
|
|
24
|
+
};
|
|
25
|
+
const fetchConfluence = async (relativeUrl, config) => {
|
|
26
|
+
const baseUrl = config.getString("confluence.baseUrl");
|
|
27
|
+
const token = config.getString("confluence.token");
|
|
28
|
+
const response = await fetch__default["default"](`${baseUrl}${relativeUrl}`, {
|
|
29
|
+
method: "GET",
|
|
30
|
+
headers: {
|
|
31
|
+
Authorization: `Bearer ${token}`
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
throw await errors.ResponseError.fromResponse(response);
|
|
36
|
+
}
|
|
37
|
+
return response.json();
|
|
38
|
+
};
|
|
39
|
+
const getAndWriteAttachments = async (arr, workspace, config, mkdocsDir) => {
|
|
40
|
+
const productArr = [];
|
|
41
|
+
const baseUrl = config.getString("confluence.baseUrl");
|
|
42
|
+
const token = config.getString("confluence.token");
|
|
43
|
+
await Promise.all(
|
|
44
|
+
await arr.results.map(async (result) => {
|
|
45
|
+
const downloadLink = result._links.download;
|
|
46
|
+
const downloadTitle = result.title.replace(/ /g, "-");
|
|
47
|
+
if (result.metadata.mediaType !== "application/gliffy+json") {
|
|
48
|
+
productArr.push([result.title.replace(/ /g, "%20"), downloadTitle]);
|
|
49
|
+
}
|
|
50
|
+
const res = await fetch__default["default"](`${baseUrl}${downloadLink}`, {
|
|
51
|
+
method: "GET",
|
|
52
|
+
headers: {
|
|
53
|
+
Authorization: `Bearer ${token}`
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
if (!res.ok) {
|
|
57
|
+
throw errors.ResponseError.fromResponse(res);
|
|
58
|
+
} else if (res.body !== null) {
|
|
59
|
+
fs__default["default"].openSync(`${workspace}/${mkdocsDir}docs/img/${downloadTitle}`, "w");
|
|
60
|
+
const writeStream = fs__default["default"].createWriteStream(
|
|
61
|
+
`${workspace}/${mkdocsDir}docs/img/${downloadTitle}`
|
|
62
|
+
);
|
|
63
|
+
res.body.pipe(writeStream);
|
|
64
|
+
await new Promise((resolve, reject) => {
|
|
65
|
+
writeStream.on("finish", () => {
|
|
66
|
+
resolve(`${workspace}/${mkdocsDir}docs/img/${downloadTitle}`);
|
|
67
|
+
});
|
|
68
|
+
writeStream.on("error", reject);
|
|
69
|
+
});
|
|
70
|
+
} else {
|
|
71
|
+
throw new errors.ConflictError(
|
|
72
|
+
"No Body on the response. Can not save images from Confluence Doc"
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
);
|
|
77
|
+
return productArr;
|
|
78
|
+
};
|
|
79
|
+
const createConfluenceVariables = async (url) => {
|
|
80
|
+
let spacekey = void 0;
|
|
81
|
+
let title = void 0;
|
|
82
|
+
let titleWithSpaces = "";
|
|
83
|
+
const params = new URL(url);
|
|
84
|
+
if (params.pathname.split("/")[1] === "display") {
|
|
85
|
+
spacekey = params.pathname.split("/")[2];
|
|
86
|
+
title = params.pathname.split("/")[3];
|
|
87
|
+
titleWithSpaces = title == null ? void 0 : title.replace(/\+/g, " ");
|
|
88
|
+
return { spacekey, title, titleWithSpaces };
|
|
89
|
+
}
|
|
90
|
+
throw new errors.InputError(
|
|
91
|
+
"The Url format for Confluence is incorrect. Acceptable format is `<CONFLUENCE_BASE_URL>/display/<SPACEKEY>/<PAGE+TITLE>`"
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const createConfluenceToMarkdownAction = (options) => {
|
|
96
|
+
const { config, reader, integrations } = options;
|
|
97
|
+
const fetchPlainAction = pluginScaffolderBackend.createFetchPlainAction({ reader, integrations });
|
|
98
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
99
|
+
id: "confluence:transform:markdown",
|
|
100
|
+
schema: {
|
|
101
|
+
input: {
|
|
102
|
+
properties: {
|
|
103
|
+
confluenceUrls: {
|
|
104
|
+
type: "array",
|
|
105
|
+
title: "Confluence URL",
|
|
106
|
+
description: "Paste your confluence url. Ensure it follows this format: https://{confluence+base+url}/display/{spacekey}/{page+title}",
|
|
107
|
+
items: {
|
|
108
|
+
type: "string",
|
|
109
|
+
default: "Confluence URL"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
repoUrl: {
|
|
113
|
+
type: "string",
|
|
114
|
+
title: "GitHub Repo Url",
|
|
115
|
+
description: "mkdocs.yml file location inside the github repo you want to store the document"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
async handler(ctx) {
|
|
121
|
+
const { confluenceUrls, repoUrl } = ctx.input;
|
|
122
|
+
const parsedRepoUrl = parseGitUrl__default["default"](repoUrl);
|
|
123
|
+
const filePathToMkdocs = parsedRepoUrl.filepath.substring(
|
|
124
|
+
0,
|
|
125
|
+
parsedRepoUrl.filepath.lastIndexOf("/") + 1
|
|
126
|
+
);
|
|
127
|
+
const dirPath = ctx.workspacePath;
|
|
128
|
+
let productArray = [];
|
|
129
|
+
ctx.logger.info(`Fetching the mkdocs.yml catalog from ${repoUrl}`);
|
|
130
|
+
const repoFileDir = `${dirPath}/${parsedRepoUrl.filepath}`;
|
|
131
|
+
await fetchPlainAction.handler({
|
|
132
|
+
...ctx,
|
|
133
|
+
input: {
|
|
134
|
+
url: `https://${parsedRepoUrl.resource}/${parsedRepoUrl.owner}/${parsedRepoUrl.name}`,
|
|
135
|
+
targetPath: dirPath
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
for (const url of confluenceUrls) {
|
|
139
|
+
const { spacekey, title, titleWithSpaces } = await createConfluenceVariables(url);
|
|
140
|
+
const getConfluenceDoc = await fetchConfluence(
|
|
141
|
+
`/rest/api/content?title=${title}&spaceKey=${spacekey}&expand=body.export_view`,
|
|
142
|
+
config
|
|
143
|
+
);
|
|
144
|
+
if (getConfluenceDoc.results.length === 0) {
|
|
145
|
+
throw new errors.InputError(
|
|
146
|
+
`Could not find document ${url}. Please check your input.`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
const getDocAttachments = await fetchConfluence(
|
|
150
|
+
`/rest/api/content/${getConfluenceDoc.results[0].id}/child/attachment`,
|
|
151
|
+
config
|
|
152
|
+
);
|
|
153
|
+
if (getDocAttachments.results.length) {
|
|
154
|
+
fs__default["default"].mkdirSync(`${dirPath}/${filePathToMkdocs}docs/img`, {
|
|
155
|
+
recursive: true
|
|
156
|
+
});
|
|
157
|
+
productArray = await getAndWriteAttachments(
|
|
158
|
+
getDocAttachments,
|
|
159
|
+
dirPath,
|
|
160
|
+
config,
|
|
161
|
+
filePathToMkdocs
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
ctx.logger.info(
|
|
165
|
+
`starting action for converting ${titleWithSpaces} from Confluence To Markdown`
|
|
166
|
+
);
|
|
167
|
+
const mkdocsFileContent = await readFileAsString(repoFileDir);
|
|
168
|
+
const mkdocsFile = await YAML__default["default"].parse(mkdocsFileContent);
|
|
169
|
+
ctx.logger.info(
|
|
170
|
+
`Adding new file - ${titleWithSpaces} to the current mkdocs.yml file`
|
|
171
|
+
);
|
|
172
|
+
if (mkdocsFile !== void 0 && mkdocsFile.hasOwnProperty("nav")) {
|
|
173
|
+
const { nav } = mkdocsFile;
|
|
174
|
+
if (!nav.some((i) => i.hasOwnProperty(titleWithSpaces))) {
|
|
175
|
+
nav.push({
|
|
176
|
+
[titleWithSpaces]: `${titleWithSpaces.replace(/\s+/g, "-")}.md`
|
|
177
|
+
});
|
|
178
|
+
mkdocsFile.nav = nav;
|
|
179
|
+
} else {
|
|
180
|
+
throw new errors.ConflictError(
|
|
181
|
+
"This document looks to exist inside the GitHub repo. Will end the action."
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
await fs__default["default"].writeFile(repoFileDir, YAML__default["default"].stringify(mkdocsFile));
|
|
186
|
+
const html = getConfluenceDoc.results[0].body.export_view.value;
|
|
187
|
+
const markdownToPublish = nodeHtmlMarkdown.NodeHtmlMarkdown.translate(html);
|
|
188
|
+
let newString = markdownToPublish;
|
|
189
|
+
productArray.forEach((product) => {
|
|
190
|
+
const regex = product[0].includes(".pdf") ? new RegExp(`(\\[.*?\\]\\()(.*?${product[0]}.*?)(\\))`, "gi") : new RegExp(`(\\!\\[.*?\\]\\()(.*?${product[0]}.*?)(\\))`, "gi");
|
|
191
|
+
newString = newString.replace(regex, `$1./img/${product[1]}$3`);
|
|
192
|
+
});
|
|
193
|
+
ctx.logger.info(`Adding new file to repo.`);
|
|
194
|
+
await fs__default["default"].outputFile(
|
|
195
|
+
`${dirPath}/${filePathToMkdocs}docs/${titleWithSpaces.replace(
|
|
196
|
+
/\s+/g,
|
|
197
|
+
"-"
|
|
198
|
+
)}.md`,
|
|
199
|
+
newString
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
ctx.output("repo", parsedRepoUrl.name);
|
|
203
|
+
ctx.output("owner", parsedRepoUrl.owner);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
exports.createConfluenceToMarkdownAction = createConfluenceToMarkdownAction;
|
|
209
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/actions/confluence/helpers.ts","../src/actions/confluence/confluenceToMarkdown.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport { ResponseError, ConflictError, InputError } from '@backstage/errors';\nimport fs from 'fs-extra';\nimport fetch, { Response } from 'node-fetch';\n\ninterface Links {\n webui: string;\n download: string;\n thumbnail: string;\n self: string;\n}\n\ninterface Metadata {\n mediaType: string;\n}\n\nexport interface Result {\n id: string;\n type: string;\n status: string;\n title: string;\n metadata: Metadata;\n _links: Links;\n}\n\nexport interface Results {\n results: Result[];\n}\n\nexport const readFileAsString = async (fileDir: string) => {\n const content = await fs.readFile(fileDir, 'utf-8');\n return content.toString();\n};\n\nexport const fetchConfluence = async (relativeUrl: string, config: Config) => {\n const baseUrl = config.getString('confluence.baseUrl');\n const token = config.getString('confluence.token');\n const response: Response = await fetch(`${baseUrl}${relativeUrl}`, {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return response.json();\n};\n\nexport const getAndWriteAttachments = async (\n arr: Results,\n workspace: string,\n config: Config,\n mkdocsDir: string,\n) => {\n const productArr: string[][] = [];\n const baseUrl = config.getString('confluence.baseUrl');\n const token = config.getString('confluence.token');\n await Promise.all(\n await arr.results.map(async (result: Result) => {\n const downloadLink = result._links.download;\n const downloadTitle = result.title.replace(/ /g, '-');\n if (result.metadata.mediaType !== 'application/gliffy+json') {\n productArr.push([result.title.replace(/ /g, '%20'), downloadTitle]);\n }\n\n const res = await fetch(`${baseUrl}${downloadLink}`, {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n if (!res.ok) {\n throw ResponseError.fromResponse(res);\n } else if (res.body !== null) {\n fs.openSync(`${workspace}/${mkdocsDir}docs/img/${downloadTitle}`, 'w');\n const writeStream = fs.createWriteStream(\n `${workspace}/${mkdocsDir}docs/img/${downloadTitle}`,\n );\n res.body.pipe(writeStream);\n await new Promise((resolve, reject) => {\n writeStream.on('finish', () => {\n resolve(`${workspace}/${mkdocsDir}docs/img/${downloadTitle}`);\n });\n writeStream.on('error', reject);\n });\n } else {\n throw new ConflictError(\n 'No Body on the response. Can not save images from Confluence Doc',\n );\n }\n }),\n );\n return productArr;\n};\n\nexport const createConfluenceVariables = async (url: string) => {\n let spacekey: string | undefined = undefined;\n let title: string | undefined = undefined;\n let titleWithSpaces: string | undefined = '';\n const params = new URL(url);\n if (params.pathname.split('/')[1] === 'display') {\n spacekey = params.pathname.split('/')[2];\n title = params.pathname.split('/')[3];\n titleWithSpaces = title?.replace(/\\+/g, ' ');\n return { spacekey, title, titleWithSpaces };\n }\n throw new InputError(\n 'The Url format for Confluence is incorrect. Acceptable format is `<CONFLUENCE_BASE_URL>/display/<SPACEKEY>/<PAGE+TITLE>`',\n );\n};\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Config } from '@backstage/config';\nimport { UrlReader } from '@backstage/backend-common';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { createFetchPlainAction } from '@backstage/plugin-scaffolder-backend';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { InputError, ConflictError } from '@backstage/errors';\nimport { NodeHtmlMarkdown } from 'node-html-markdown';\nimport fs from 'fs-extra';\nimport parseGitUrl from 'git-url-parse';\nimport YAML from 'yaml';\nimport {\n readFileAsString,\n fetchConfluence,\n getAndWriteAttachments,\n createConfluenceVariables,\n} from './helpers';\n\n/**\n * @public\n */\n\nexport const createConfluenceToMarkdownAction = (options: {\n reader: UrlReader;\n integrations: ScmIntegrations;\n config: Config;\n}) => {\n const { config, reader, integrations } = options;\n const fetchPlainAction = createFetchPlainAction({ reader, integrations });\n type Obj = {\n [key: string]: string;\n };\n\n return createTemplateAction<{\n confluenceUrls: string[];\n repoUrl: string;\n }>({\n id: 'confluence:transform:markdown',\n schema: {\n input: {\n properties: {\n confluenceUrls: {\n type: 'array',\n title: 'Confluence URL',\n description:\n 'Paste your confluence url. Ensure it follows this format: https://{confluence+base+url}/display/{spacekey}/{page+title}',\n items: {\n type: 'string',\n default: 'Confluence URL',\n },\n },\n repoUrl: {\n type: 'string',\n title: 'GitHub Repo Url',\n description:\n 'mkdocs.yml file location inside the github repo you want to store the document',\n },\n },\n },\n },\n async handler(ctx) {\n const { confluenceUrls, repoUrl } = ctx.input;\n const parsedRepoUrl = parseGitUrl(repoUrl);\n const filePathToMkdocs = parsedRepoUrl.filepath.substring(\n 0,\n parsedRepoUrl.filepath.lastIndexOf('/') + 1,\n );\n const dirPath = ctx.workspacePath;\n let productArray: string[][] = [];\n\n ctx.logger.info(`Fetching the mkdocs.yml catalog from ${repoUrl}`);\n\n // This grabs the files from Github\n const repoFileDir = `${dirPath}/${parsedRepoUrl.filepath}`;\n await fetchPlainAction.handler({\n ...ctx,\n input: {\n url: `https://${parsedRepoUrl.resource}/${parsedRepoUrl.owner}/${parsedRepoUrl.name}`,\n targetPath: dirPath,\n },\n });\n\n for (const url of confluenceUrls) {\n const { spacekey, title, titleWithSpaces } =\n await createConfluenceVariables(url);\n // This calls confluence to get the page html and page id\n const getConfluenceDoc = await fetchConfluence(\n `/rest/api/content?title=${title}&spaceKey=${spacekey}&expand=body.export_view`,\n config,\n );\n if (getConfluenceDoc.results.length === 0) {\n throw new InputError(\n `Could not find document ${url}. Please check your input.`,\n );\n }\n // This gets attachements for the confluence page if they exist\n const getDocAttachments = await fetchConfluence(\n `/rest/api/content/${getConfluenceDoc.results[0].id}/child/attachment`,\n config,\n );\n\n if (getDocAttachments.results.length) {\n fs.mkdirSync(`${dirPath}/${filePathToMkdocs}docs/img`, {\n recursive: true,\n });\n productArray = await getAndWriteAttachments(\n getDocAttachments,\n dirPath,\n config,\n filePathToMkdocs,\n );\n }\n\n ctx.logger.info(\n `starting action for converting ${titleWithSpaces} from Confluence To Markdown`,\n );\n\n // This reads mkdocs.yml file\n const mkdocsFileContent = await readFileAsString(repoFileDir);\n const mkdocsFile = await YAML.parse(mkdocsFileContent);\n ctx.logger.info(\n `Adding new file - ${titleWithSpaces} to the current mkdocs.yml file`,\n );\n\n // This modifies the mkdocs.yml file\n if (mkdocsFile !== undefined && mkdocsFile.hasOwnProperty('nav')) {\n const { nav } = mkdocsFile;\n if (!nav.some((i: Obj) => i.hasOwnProperty(titleWithSpaces))) {\n nav.push({\n [titleWithSpaces]: `${titleWithSpaces.replace(/\\s+/g, '-')}.md`,\n });\n mkdocsFile.nav = nav;\n } else {\n throw new ConflictError(\n 'This document looks to exist inside the GitHub repo. Will end the action.',\n );\n }\n }\n\n await fs.writeFile(repoFileDir, YAML.stringify(mkdocsFile));\n\n // This grabs the confluence html and converts it to markdown and adds attachments\n const html = getConfluenceDoc.results[0].body.export_view.value;\n const markdownToPublish = NodeHtmlMarkdown.translate(html);\n let newString: string = markdownToPublish;\n productArray.forEach((product: string[]) => {\n // This regex is looking for either [](link to confluence) or  in the newly created markdown doc and updating it to point to the versions saved(in ./docs/img) in the local version of GitHub Repo during getAndWriteAttachments\n const regex = product[0].includes('.pdf')\n ? new RegExp(`(\\\\[.*?\\\\]\\\\()(.*?${product[0]}.*?)(\\\\))`, 'gi')\n : new RegExp(`(\\\\!\\\\[.*?\\\\]\\\\()(.*?${product[0]}.*?)(\\\\))`, 'gi');\n newString = newString.replace(regex, `$1./img/${product[1]}$3`);\n });\n\n ctx.logger.info(`Adding new file to repo.`);\n await fs.outputFile(\n `${dirPath}/${filePathToMkdocs}docs/${titleWithSpaces.replace(\n /\\s+/g,\n '-',\n )}.md`,\n newString,\n );\n }\n\n ctx.output('repo', parsedRepoUrl.name);\n ctx.output('owner', parsedRepoUrl.owner);\n },\n });\n};\n"],"names":["fs","fetch","ResponseError","ConflictError","InputError","createFetchPlainAction","createTemplateAction","parseGitUrl","YAML","NodeHtmlMarkdown"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6Ca,MAAA,gBAAA,GAAmB,OAAO,OAAoB,KAAA;AACzD,EAAA,MAAM,OAAU,GAAA,MAAMA,sBAAG,CAAA,QAAA,CAAS,SAAS,OAAO,CAAA,CAAA;AAClD,EAAA,OAAO,QAAQ,QAAS,EAAA,CAAA;AAC1B,CAAA,CAAA;AAEa,MAAA,eAAA,GAAkB,OAAO,WAAA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pC,IAAI,MAAO,CAAA,CAAA,kBAAA,EAAqB,QAAQ,CAAC,CAAA,CAAA,SAAA,CAAA,EAAc,IAAI,CAC3D,GAAA,IAAI,OAAO,CAAwB,qBAAA,EAAA,OAAA,CAAQ,CAAC,CAAA,CAAA,SAAA,CAAA,EAAc,IAAI,CAAA,CAAA;AAClE,UAAA,SAAA,GAAY,UAAU,OAAQ,CAAA,KAAA,EAAO,CAAW,QAAA,EAAA,OAAA,CAAQ,CAAC,CAAK,CAAA,EAAA,CAAA,CAAA,CAAA;AAAA,SAC/D,CAAA,CAAA;AAED,QAAI,GAAA,CAAA,MAAA,CAAO,KAAK,CAA0B,wBAAA,CAAA,CAAA,CAAA;AAC1C,QAAA,MAAMT,sBAAG,CAAA,UAAA;AAAA,UACP,CAAA,EAAG,OAAW,CAAA,CAAA,EAAA,gBAAA,CAAA,KAAA,EAAwB,eAAgB,CAAA,OAAA;AAAA,YACpD,MAAA;AAAA,YACA,GAAA;AAAA,WACF,CAAA,GAAA,CAAA;AAAA,UACA,SAAA;AAAA,SACF,CAAA;AAAA,OACF;AAEA,MAAI,GAAA,CAAA,MAAA,CAAO,MAAQ,EAAA,aAAA,CAAc,IAAI,CAAA,CAAA;AACrC,MAAI,GAAA,CAAA,MAAA,CAAO,OAAS,EAAA,aAAA,CAAc,KAAK,CAAA,CAAA;AAAA,KACzC;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as _backstage_plugin_scaffolder_node from '@backstage/plugin-scaffolder-node';
|
|
2
|
+
import { Config } from '@backstage/config';
|
|
3
|
+
import { UrlReader } from '@backstage/backend-common';
|
|
4
|
+
import { ScmIntegrations } from '@backstage/integration';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
declare const createConfluenceToMarkdownAction: (options: {
|
|
10
|
+
reader: UrlReader;
|
|
11
|
+
integrations: ScmIntegrations;
|
|
12
|
+
config: Config;
|
|
13
|
+
}) => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
14
|
+
confluenceUrls: string[];
|
|
15
|
+
repoUrl: string;
|
|
16
|
+
}>;
|
|
17
|
+
|
|
18
|
+
export { createConfluenceToMarkdownAction };
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@backstage/plugin-scaffolder-backend-module-confluence-to-markdown",
|
|
3
|
+
"description": "The confluence-to-markdown module for @backstage/plugin-scaffolder-backend",
|
|
4
|
+
"version": "0.0.0-nightly-20230325022054",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public",
|
|
10
|
+
"main": "dist/index.cjs.js",
|
|
11
|
+
"types": "dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"backstage": {
|
|
14
|
+
"role": "backend-plugin-module"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"start": "backstage-cli package start",
|
|
18
|
+
"build": "backstage-cli package build",
|
|
19
|
+
"lint": "backstage-cli package lint",
|
|
20
|
+
"test": "backstage-cli package test",
|
|
21
|
+
"clean": "backstage-cli package clean",
|
|
22
|
+
"prepack": "backstage-cli package prepack",
|
|
23
|
+
"postpack": "backstage-cli package postpack",
|
|
24
|
+
"help": "backstage-cli help"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@backstage/backend-common": "^0.0.0-nightly-20230325022054",
|
|
28
|
+
"@backstage/config": "^1.0.7",
|
|
29
|
+
"@backstage/errors": "^1.1.5",
|
|
30
|
+
"@backstage/integration": "^1.4.3",
|
|
31
|
+
"@backstage/plugin-scaffolder-backend": "^0.0.0-nightly-20230325022054",
|
|
32
|
+
"@backstage/plugin-scaffolder-node": "^0.0.0-nightly-20230325022054",
|
|
33
|
+
"@backstage/types": "^1.0.2",
|
|
34
|
+
"fs-extra": "10.1.0",
|
|
35
|
+
"git-url-parse": "^13.1.0",
|
|
36
|
+
"node-fetch": "^2.6.7",
|
|
37
|
+
"node-html-markdown": "^1.3.0",
|
|
38
|
+
"yaml": "^2.0.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@backstage/cli": "^0.0.0-nightly-20230325022054",
|
|
42
|
+
"@backstage/test-utils": "^0.0.0-nightly-20230325022054",
|
|
43
|
+
"mock-fs": "^5.2.0",
|
|
44
|
+
"msw": "^1.0.0"
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"dist"
|
|
48
|
+
]
|
|
49
|
+
}
|