@backstage/plugin-scaffolder-backend-module-confluence-to-markdown 0.1.3-next.0 → 0.1.3-next.2

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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-confluence-to-markdown
2
2
 
3
+ ## 0.1.3-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/plugin-scaffolder-backend@1.15.0-next.2
9
+ - @backstage/config@1.0.7
10
+
11
+ ## 0.1.3-next.1
12
+
13
+ ### Patch Changes
14
+
15
+ - c59a4b2b9e0a: Added support for Confluence Cloud to the `confluence:transform:markdown` action in addition to the existing Confluence Server support, view the [README](https://github.com/backstage/backstage/tree/master/plugins/scaffolder-backend-module-confluence-to-markdown) for more details
16
+ - Updated dependencies
17
+ - @backstage/backend-common@0.19.0-next.1
18
+ - @backstage/integration@1.5.0-next.0
19
+ - @backstage/errors@1.2.0-next.0
20
+ - @backstage/plugin-scaffolder-backend@1.15.0-next.1
21
+ - @backstage/plugin-scaffolder-node@0.1.4-next.1
22
+ - @backstage/config@1.0.7
23
+ - @backstage/types@1.0.2
24
+
3
25
  ## 0.1.3-next.0
4
26
 
5
27
  ### Patch Changes
package/README.md CHANGED
@@ -4,16 +4,18 @@ Welcome to the `confluence:transform:markdown` action for the `scaffolder-backen
4
4
 
5
5
  ## Getting started
6
6
 
7
- You need to configure the action in your backend:
7
+ The following sections will help you getting started
8
8
 
9
- ## From your Backstage root directory
9
+ ### Configure Action in Backend
10
+
11
+ From your Backstage root directory run:
10
12
 
11
13
  ```bash
12
14
  # From your Backstage root directory
13
15
  yarn add --cwd packages/backend @backstage/plugin-scaffolder-backend-module-confluence-to-markdown
14
16
  ```
15
17
 
16
- Configure the action:
18
+ Then configure the action:
17
19
  (you can check the [docs](https://backstage.io/docs/features/software-templates/writing-custom-actions#registering-custom-actions) to see all options):
18
20
 
19
21
  ```typescript
@@ -56,15 +58,62 @@ export default async function createPlugin(
56
58
  }
57
59
  ```
58
60
 
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`
61
+ ### Configuration
62
+
63
+ There is some configuration that needs to be setup to use this action, these are the base parameters:
64
+
65
+ ```yaml
66
+ confluence:
67
+ baseUrl: 'https://confluence.example.com'
68
+ token: '${CONFLUENCE_TOKEN}'
69
+ ```
70
+
71
+ The sections below will go into more details about the Base URL and Auth Methods.
72
+
73
+ #### Base URL
74
+
75
+ The `baseUrl` for Confluence Cloud should include the product name which is `wiki` by default but can be something else if your Org has changed it. An example `baseUrl` for Confluence Cloud would look like this: `https://example.atlassian.net/wiki`
76
+
77
+ If you are using a self-hosted Confluence instance this does not apply to you. Your `baseUrl` would look something like this: `https://confluence.example.com`
78
+
79
+ #### Auth Methods
80
+
81
+ The default authorization method is `bearer` but `basic` and `userpass` are also supported. Here's how you would configure each of these:
82
+
83
+ For `bearer`:
60
84
 
61
85
  ```yaml
62
86
  confluence:
63
- baseUrl: ${CONFLUENCE_BASE_URL}
64
- token: ${CONFLUENCE_TOKEN}
87
+ baseUrl: 'https://confluence.example.com'
88
+ auth: 'bearer'
89
+ token: '${CONFLUENCE_TOKEN}'
65
90
  ```
66
91
 
67
- After that you can use the action in your template:
92
+ For `basic`:
93
+
94
+ ```yaml
95
+ confluence:
96
+ baseUrl: 'https://confluence.example.com'
97
+ auth: 'basic'
98
+ token: '${CONFLUENCE_TOKEN}'
99
+ email: 'example@company.org'
100
+ ```
101
+
102
+ For `userpass`
103
+
104
+ ```yaml
105
+ confluence:
106
+ baseUrl: 'https://confluence.example.com'
107
+ auth: 'userpass'
108
+ username: 'your-username'
109
+ password: 'your-password'
110
+ ```
111
+
112
+ **Note:** For `basic` and `bearer` authorization methods you will need an access token for authorization with `Read` permissions. You can create a Personal Access Token (PAT) in Confluence. The value used should be the raw token as it will be encoded for you by the action.
113
+
114
+ ### Template Usage
115
+
116
+ Here's an example of how you can use the action in your template:
68
117
 
69
118
  ```yaml
70
119
  apiVersion: scaffolder.backstage.io/v1beta3
@@ -72,7 +121,7 @@ kind: Template
72
121
  metadata:
73
122
  name: confluence-to-markdown
74
123
  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.
124
+ description: This template converts a single Confluence document to Markdown for Techdocs and adds it to a given GitHub repo.
76
125
  tags:
77
126
  - do-not-use
78
127
  - poc
@@ -84,10 +133,9 @@ spec:
84
133
  properties:
85
134
  confluenceUrls:
86
135
  type: array
87
- description: Urls for confluence doc to be converted to markdown. In format <CONFLUENCE_BASE_URL>/display/<SPACEKEY>/<PAGE+TITLE>
136
+ description: Urls for Confluence doc to be converted to markdown. In format <CONFLUENCE_BASE_URL>/display/<SPACEKEY>/<PAGE+TITLE> or <CONFLUENCE_BASE_URL>/spaces/<SPACEKEY>/pages/<PAGEID>/<PAGE+TITLE> for Confluence cloud
88
137
  items:
89
138
  type: string
90
- default: confluence url
91
139
  ui:options:
92
140
  addable: true
93
141
  minItems: 1
@@ -110,9 +158,9 @@ spec:
110
158
  repoUrl: <GITHUB_BASE_URL>?repo=${{ steps['create-docs'].output.repo }}&owner=${{ steps['create-docs'].output.owner }}
111
159
  branchName: confluence-to-markdown
112
160
  title: Confluence to Markdown
113
- description: PR for converting confluence page to mkdocs
161
+ description: PR for converting Confluence page to mkdocs
114
162
  ```
115
163
 
116
164
  Replace `<GITHUB_BASE_URL>` with your GitHub URL without `https://`.
117
165
 
118
- You can find a list of all registered actions including their parameters at the /create/actions route in your Backstage application.
166
+ You can find a list of all registered actions including their parameters at the `/create/actions` route in your Backstage application.
package/config.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Copyright 2023 The Backstage Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ export interface Config {
18
+ /** Configuration options for the Confluence to Markdown action */
19
+ confluence?: {
20
+ /**
21
+ * The base URL for accessing the Confluence API
22
+ */
23
+ baseUrl: string;
24
+ /**
25
+ * Authentication method - basic, bearer, username/password
26
+ */
27
+ auth: 'basic' | 'bearer' | 'userpass';
28
+ /**
29
+ * Token used for the basic and bearer auth methods
30
+ * @visibility secret
31
+ */
32
+ token?: string;
33
+ /**
34
+ * Email used with the token for the basic auth method
35
+ * @visibility secret
36
+ */
37
+ email?: string;
38
+ /**
39
+ * Username used with the Username/Password auth method
40
+ * @visibility secret
41
+ */
42
+ username?: string;
43
+ /**
44
+ * Password used with the Username/Password auth method
45
+ * @visibility secret
46
+ */
47
+ password?: string;
48
+ };
49
+ }
package/dist/index.cjs.js CHANGED
@@ -18,17 +18,64 @@ var parseGitUrl__default = /*#__PURE__*/_interopDefaultLegacy(parseGitUrl);
18
18
  var YAML__default = /*#__PURE__*/_interopDefaultLegacy(YAML);
19
19
  var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
20
20
 
21
+ const getConfluenceConfig = (config) => {
22
+ var _a;
23
+ const confluenceConfig = {
24
+ baseUrl: config.getString("confluence.baseUrl"),
25
+ auth: (_a = config.getOptionalString("confluence.auth")) != null ? _a : "bearer",
26
+ token: config.getOptionalString("confluence.token"),
27
+ email: config.getOptionalString("confluence.email"),
28
+ username: config.getOptionalString("confluence.username"),
29
+ password: config.getOptionalString("confluence.password")
30
+ };
31
+ if ((confluenceConfig.auth === "basic" || confluenceConfig.auth === "bearer") && !confluenceConfig.token) {
32
+ throw new Error(
33
+ `No token provided for the configured '${confluenceConfig.auth}' auth method`
34
+ );
35
+ }
36
+ if (confluenceConfig.auth === "basic" && !confluenceConfig.email) {
37
+ throw new Error(
38
+ `No email provided for the configured '${confluenceConfig.auth}' auth method`
39
+ );
40
+ }
41
+ if (confluenceConfig.auth === "userpass" && (!confluenceConfig.username || !confluenceConfig.password)) {
42
+ throw new Error(
43
+ `No username/password provided for the configured '${confluenceConfig.auth}' auth method`
44
+ );
45
+ }
46
+ return confluenceConfig;
47
+ };
48
+ const getAuthorizationHeaderValue = (config) => {
49
+ switch (config.auth) {
50
+ case "bearer":
51
+ return `Bearer ${config.token}`;
52
+ case "basic": {
53
+ const buffer = Buffer.from(`${config.email}:${config.token}`, "utf8");
54
+ return `Basic ${buffer.toString("base64")}`;
55
+ }
56
+ case "userpass": {
57
+ const buffer = Buffer.from(
58
+ `${config.username}:${config.password}`,
59
+ "utf8"
60
+ );
61
+ return `Basic ${buffer.toString("base64")}`;
62
+ }
63
+ default:
64
+ throw new Error(`Unknown auth method '${config.auth}' provided`);
65
+ }
66
+ };
21
67
  const readFileAsString = async (fileDir) => {
22
68
  const content = await fs__default["default"].readFile(fileDir, "utf-8");
23
69
  return content.toString();
24
70
  };
25
71
  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}`, {
72
+ const baseUrl = config.baseUrl;
73
+ const authHeaderValue = getAuthorizationHeaderValue(config);
74
+ const url = `${baseUrl}${relativeUrl}`;
75
+ const response = await fetch__default["default"](url, {
29
76
  method: "GET",
30
77
  headers: {
31
- Authorization: `Bearer ${token}`
78
+ Authorization: authHeaderValue
32
79
  }
33
80
  });
34
81
  if (!response.ok) {
@@ -38,8 +85,8 @@ const fetchConfluence = async (relativeUrl, config) => {
38
85
  };
39
86
  const getAndWriteAttachments = async (arr, workspace, config, mkdocsDir) => {
40
87
  const productArr = [];
41
- const baseUrl = config.getString("confluence.baseUrl");
42
- const token = config.getString("confluence.token");
88
+ const baseUrl = config.baseUrl;
89
+ const authHeaderValue = getAuthorizationHeaderValue(config);
43
90
  await Promise.all(
44
91
  await arr.results.map(async (result) => {
45
92
  const downloadLink = result._links.download;
@@ -47,10 +94,11 @@ const getAndWriteAttachments = async (arr, workspace, config, mkdocsDir) => {
47
94
  if (result.metadata.mediaType !== "application/gliffy+json") {
48
95
  productArr.push([result.title.replace(/ /g, "%20"), downloadTitle]);
49
96
  }
50
- const res = await fetch__default["default"](`${baseUrl}${downloadLink}`, {
97
+ const url = `${baseUrl}${downloadLink}`;
98
+ const res = await fetch__default["default"](url, {
51
99
  method: "GET",
52
100
  headers: {
53
- Authorization: `Bearer ${token}`
101
+ Authorization: authHeaderValue
54
102
  }
55
103
  });
56
104
  if (!res.ok) {
@@ -76,7 +124,7 @@ const getAndWriteAttachments = async (arr, workspace, config, mkdocsDir) => {
76
124
  );
77
125
  return productArr;
78
126
  };
79
- const createConfluenceVariables = async (url) => {
127
+ const createConfluenceVariables = (url) => {
80
128
  let spacekey = void 0;
81
129
  let title = void 0;
82
130
  let titleWithSpaces = "";
@@ -86,9 +134,19 @@ const createConfluenceVariables = async (url) => {
86
134
  title = params.pathname.split("/")[3];
87
135
  titleWithSpaces = title == null ? void 0 : title.replace(/\+/g, " ");
88
136
  return { spacekey, title, titleWithSpaces };
137
+ } else if (params.pathname.split("/")[2] === "display") {
138
+ spacekey = params.pathname.split("/")[3];
139
+ title = params.pathname.split("/")[4];
140
+ titleWithSpaces = title == null ? void 0 : title.replace(/\+/g, " ");
141
+ return { spacekey, title, titleWithSpaces };
142
+ } else if (params.pathname.split("/")[2] === "spaces") {
143
+ spacekey = params.pathname.split("/")[3];
144
+ title = params.pathname.split("/")[6];
145
+ titleWithSpaces = title == null ? void 0 : title.replace(/\+/g, " ");
146
+ return { spacekey, title, titleWithSpaces };
89
147
  }
90
148
  throw new errors.InputError(
91
- "The Url format for Confluence is incorrect. Acceptable format is `<CONFLUENCE_BASE_URL>/display/<SPACEKEY>/<PAGE+TITLE>`"
149
+ "The Url format for Confluence is incorrect. Acceptable format is `<CONFLUENCE_BASE_URL>/display/<SPACEKEY>/<PAGE+TITLE>` or `<CONFLUENCE_BASE_URL>/spaces/<SPACEKEY>/pages/<PAGEID>/<PAGE+TITLE>` for Confluence cloud"
92
150
  );
93
151
  };
94
152
 
@@ -103,7 +161,7 @@ const createConfluenceToMarkdownAction = (options) => {
103
161
  confluenceUrls: {
104
162
  type: "array",
105
163
  title: "Confluence URL",
106
- description: "Paste your confluence url. Ensure it follows this format: https://{confluence+base+url}/display/{spacekey}/{page+title}",
164
+ description: "Paste your Confluence url. Ensure it follows this format: https://{confluence+base+url}/display/{spacekey}/{page+title} or https://{confluence+base+url}/spaces/{spacekey}/pages/1234567/{page+title} for Confluence Cloud",
107
165
  items: {
108
166
  type: "string",
109
167
  default: "Confluence URL"
@@ -118,6 +176,7 @@ const createConfluenceToMarkdownAction = (options) => {
118
176
  }
119
177
  },
120
178
  async handler(ctx) {
179
+ const confluenceConfig = getConfluenceConfig(config);
121
180
  const { confluenceUrls, repoUrl } = ctx.input;
122
181
  const parsedRepoUrl = parseGitUrl__default["default"](repoUrl);
123
182
  const filePathToMkdocs = parsedRepoUrl.filepath.substring(
@@ -136,10 +195,11 @@ const createConfluenceToMarkdownAction = (options) => {
136
195
  }
137
196
  });
138
197
  for (const url of confluenceUrls) {
139
- const { spacekey, title, titleWithSpaces } = await createConfluenceVariables(url);
198
+ const { spacekey, title, titleWithSpaces } = createConfluenceVariables(url);
199
+ ctx.logger.info(`Fetching the Confluence content for ${url}`);
140
200
  const getConfluenceDoc = await fetchConfluence(
141
201
  `/rest/api/content?title=${title}&spaceKey=${spacekey}&expand=body.export_view`,
142
- config
202
+ confluenceConfig
143
203
  );
144
204
  if (getConfluenceDoc.results.length === 0) {
145
205
  throw new errors.InputError(
@@ -148,7 +208,7 @@ const createConfluenceToMarkdownAction = (options) => {
148
208
  }
149
209
  const getDocAttachments = await fetchConfluence(
150
210
  `/rest/api/content/${getConfluenceDoc.results[0].id}/child/attachment`,
151
- config
211
+ confluenceConfig
152
212
  );
153
213
  if (getDocAttachments.results.length) {
154
214
  fs__default["default"].mkdirSync(`${dirPath}/${filePathToMkdocs}docs/img`, {
@@ -157,7 +217,7 @@ const createConfluenceToMarkdownAction = (options) => {
157
217
  productArray = await getAndWriteAttachments(
158
218
  getDocAttachments,
159
219
  dirPath,
160
- config,
220
+ confluenceConfig,
161
221
  filePathToMkdocs
162
222
  );
163
223
  }
@@ -1 +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 await 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 attachments 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 ![](link to confluence) 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,EAAqB,MAAmB,KAAA;AAC5E,EAAM,MAAA,OAAA,GAAU,MAAO,CAAA,SAAA,CAAU,oBAAoB,CAAA,CAAA;AACrD,EAAM,MAAA,KAAA,GAAQ,MAAO,CAAA,SAAA,CAAU,kBAAkB,CAAA,CAAA;AACjD,EAAA,MAAM,QAAqB,GAAA,MAAMC,yBAAM,CAAA,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AAA,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;;;;"}
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 type ConfluenceConfig = {\n baseUrl: string;\n auth: string;\n token?: string;\n email?: string;\n username?: string;\n password?: string;\n};\n\nexport const getConfluenceConfig = (config: Config) => {\n const confluenceConfig: ConfluenceConfig = {\n baseUrl: config.getString('confluence.baseUrl'),\n auth: config.getOptionalString('confluence.auth') ?? 'bearer',\n token: config.getOptionalString('confluence.token'),\n email: config.getOptionalString('confluence.email'),\n username: config.getOptionalString('confluence.username'),\n password: config.getOptionalString('confluence.password'),\n };\n\n if (\n (confluenceConfig.auth === 'basic' || confluenceConfig.auth === 'bearer') &&\n !confluenceConfig.token\n ) {\n throw new Error(\n `No token provided for the configured '${confluenceConfig.auth}' auth method`,\n );\n }\n\n if (confluenceConfig.auth === 'basic' && !confluenceConfig.email) {\n throw new Error(\n `No email provided for the configured '${confluenceConfig.auth}' auth method`,\n );\n }\n\n if (\n confluenceConfig.auth === 'userpass' &&\n (!confluenceConfig.username || !confluenceConfig.password)\n ) {\n throw new Error(\n `No username/password provided for the configured '${confluenceConfig.auth}' auth method`,\n );\n }\n\n return confluenceConfig;\n};\n\nexport const getAuthorizationHeaderValue = (config: ConfluenceConfig) => {\n switch (config.auth) {\n case 'bearer':\n return `Bearer ${config.token}`;\n case 'basic': {\n const buffer = Buffer.from(`${config.email}:${config.token}`, 'utf8');\n return `Basic ${buffer.toString('base64')}`;\n }\n case 'userpass': {\n const buffer = Buffer.from(\n `${config.username}:${config.password}`,\n 'utf8',\n );\n return `Basic ${buffer.toString('base64')}`;\n }\n default:\n throw new Error(`Unknown auth method '${config.auth}' provided`);\n }\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 (\n relativeUrl: string,\n config: ConfluenceConfig,\n) => {\n const baseUrl = config.baseUrl;\n const authHeaderValue = getAuthorizationHeaderValue(config);\n const url = `${baseUrl}${relativeUrl}`;\n const response: Response = await fetch(url, {\n method: 'GET',\n headers: {\n Authorization: authHeaderValue,\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: ConfluenceConfig,\n mkdocsDir: string,\n) => {\n const productArr: string[][] = [];\n const baseUrl = config.baseUrl;\n const authHeaderValue = getAuthorizationHeaderValue(config);\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 const url = `${baseUrl}${downloadLink}`;\n const res = await fetch(url, {\n method: 'GET',\n headers: {\n Authorization: authHeaderValue,\n },\n });\n if (!res.ok) {\n throw await 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 = (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 // https://confluence.example.com/display/SPACEKEY/Page+Title\n spacekey = params.pathname.split('/')[2];\n title = params.pathname.split('/')[3];\n titleWithSpaces = title?.replace(/\\+/g, ' ');\n return { spacekey, title, titleWithSpaces };\n } else if (params.pathname.split('/')[2] === 'display') {\n // https://confluence.example.com/prefix/display/SPACEKEY/Page+Title\n spacekey = params.pathname.split('/')[3];\n title = params.pathname.split('/')[4];\n titleWithSpaces = title?.replace(/\\+/g, ' ');\n return { spacekey, title, titleWithSpaces };\n } else if (params.pathname.split('/')[2] === 'spaces') {\n // https://example.atlassian.net/wiki/spaces/SPACEKEY/pages/1234567/Page+Title\n spacekey = params.pathname.split('/')[3];\n title = params.pathname.split('/')[6];\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>` or `<CONFLUENCE_BASE_URL>/spaces/<SPACEKEY>/pages/<PAGEID>/<PAGE+TITLE>` for Confluence cloud',\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 getConfluenceConfig,\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} or https://{confluence+base+url}/spaces/{spacekey}/pages/1234567/{page+title} for Confluence Cloud',\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 confluenceConfig = getConfluenceConfig(config);\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 createConfluenceVariables(url);\n // This calls confluence to get the page html and page id\n ctx.logger.info(`Fetching the Confluence content for ${url}`);\n const getConfluenceDoc = await fetchConfluence(\n `/rest/api/content?title=${title}&spaceKey=${spacekey}&expand=body.export_view`,\n confluenceConfig,\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 attachments for the confluence page if they exist\n const getDocAttachments = await fetchConfluence(\n `/rest/api/content/${getConfluenceDoc.results[0].id}/child/attachment`,\n confluenceConfig,\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 confluenceConfig,\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 ![](link to confluence) 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":";;;;;;;;;;;;;;;;;;;;AAsDa,MAAA,mBAAA,GAAsB,CAAC,MAAmB,KAAA;AAtDvD,EAAA,IAAA,EAAA,CAAA;AAuDE,EAAA,MAAM,gBAAqC,GAAA;AAAA,IACzC,OAAA,EAAS,MAAO,CAAA,SAAA,CAAU,oBAAoB,CAAA;AAAA,IAC9C,IAAM,EAAA,CAAA,EAAA,GAAA,MAAA,CAAO,iBAAkB,CAAA,iBAAiB,MAA1C,IAA+C,GAAA,EAAA,GAAA,QAAA;AAAA,IACrD,KAAA,EAAO,MAAO,CAAA,iBAAA,CAAkB,kBAAkB,CAAA;AAAA,IAClD,KAAA,EAAO,MAAO,CAAA,iBAAA,CAAkB,kBAAkB,CAAA;AAAA,IAClD,QAAA,EAAU,MAAO,CAAA,iBAAA,CAAkB,qBAAqB,CAAA;AAAA,IACxD,QAAA,EAAU,MAAO,CAAA,iBAAA,CAAkB,qBAAqB,CAAA;AAAA,GAC1D,CAAA;AAEA,EACG,IAAA,CAAA,gBAAA,CAAiB,SAAS,OAAW,IAAA,gBAAA,CAAiB,SAAS,QAChE,KAAA,CAAC,iBAAiB,KAClB,EAAA;AACA,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,yCAAyC,gBAAiB,CAAA,IAAA,CAAA,aAAA,CAAA;AAAA,KAC5D,CAAA;AAAA,GACF;AAEA,EAAA,IAAI,gBAAiB,CAAA,IAAA,KAAS,OAAW,IAAA,CAAC,iBAAiB,KAAO,EAAA;AAChE,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,yCA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C,CAAA,CAAE,SAAS,MAAM,CAAA,GACpC,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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-confluence-to-markdown",
3
3
  "description": "The confluence-to-markdown module for @backstage/plugin-scaffolder-backend",
4
- "version": "0.1.3-next.0",
4
+ "version": "0.1.3-next.2",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -24,12 +24,12 @@
24
24
  "help": "backstage-cli help"
25
25
  },
26
26
  "dependencies": {
27
- "@backstage/backend-common": "^0.18.6-next.0",
27
+ "@backstage/backend-common": "^0.19.0-next.1",
28
28
  "@backstage/config": "^1.0.7",
29
- "@backstage/errors": "^1.1.5",
30
- "@backstage/integration": "^1.4.5",
31
- "@backstage/plugin-scaffolder-backend": "^1.14.1-next.0",
32
- "@backstage/plugin-scaffolder-node": "^0.1.4-next.0",
29
+ "@backstage/errors": "^1.2.0-next.0",
30
+ "@backstage/integration": "^1.5.0-next.0",
31
+ "@backstage/plugin-scaffolder-backend": "^1.15.0-next.2",
32
+ "@backstage/plugin-scaffolder-node": "^0.1.4-next.1",
33
33
  "@backstage/types": "^1.0.2",
34
34
  "fs-extra": "10.1.0",
35
35
  "git-url-parse": "^13.1.0",
@@ -38,12 +38,14 @@
38
38
  "yaml": "^2.0.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@backstage/backend-test-utils": "^0.1.38-next.0",
42
- "@backstage/cli": "^0.22.8-next.0",
41
+ "@backstage/backend-test-utils": "^0.1.38-next.1",
42
+ "@backstage/cli": "^0.22.8-next.1",
43
43
  "mock-fs": "^5.2.0",
44
44
  "msw": "^1.0.0"
45
45
  },
46
46
  "files": [
47
- "dist"
48
- ]
47
+ "dist",
48
+ "config.d.ts"
49
+ ],
50
+ "configSchema": "config.d.ts"
49
51
  }