@backstage/plugin-scaffolder-backend-module-confluence-to-markdown 0.3.10-next.0 → 0.3.10-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,28 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-confluence-to-markdown
|
|
2
2
|
|
|
3
|
+
## 0.3.10-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/plugin-scaffolder-node@0.9.0-next.2
|
|
9
|
+
- @backstage/backend-plugin-api@1.4.0-next.1
|
|
10
|
+
- @backstage/config@1.3.2
|
|
11
|
+
- @backstage/errors@1.2.7
|
|
12
|
+
- @backstage/integration@1.17.0
|
|
13
|
+
|
|
14
|
+
## 0.3.10-next.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 4a86bca: Migrate actions to new format
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @backstage/plugin-scaffolder-node@0.8.3-next.1
|
|
21
|
+
- @backstage/backend-plugin-api@1.4.0-next.1
|
|
22
|
+
- @backstage/config@1.3.2
|
|
23
|
+
- @backstage/errors@1.2.7
|
|
24
|
+
- @backstage/integration@1.17.0
|
|
25
|
+
|
|
3
26
|
## 0.3.10-next.0
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -23,22 +23,20 @@ const createConfluenceToMarkdownAction = (options) => {
|
|
|
23
23
|
examples: confluenceToMarkdown_examples.examples,
|
|
24
24
|
schema: {
|
|
25
25
|
input: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
}
|
|
26
|
+
confluenceUrls: (z) => z.array(z.string(), {
|
|
27
|
+
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"
|
|
28
|
+
}),
|
|
29
|
+
repoUrl: (z) => z.string({
|
|
30
|
+
description: "mkdocs.yml file location inside the github repo you want to store the document"
|
|
31
|
+
})
|
|
32
|
+
},
|
|
33
|
+
output: {
|
|
34
|
+
repo: (z) => z.string({
|
|
35
|
+
description: "Repository name"
|
|
36
|
+
}).optional(),
|
|
37
|
+
owner: (z) => z.string({
|
|
38
|
+
description: "Repository owner"
|
|
39
|
+
}).optional()
|
|
42
40
|
}
|
|
43
41
|
},
|
|
44
42
|
async handler(ctx) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confluenceToMarkdown.cjs.js","sources":["../../../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 { ScmIntegrations } from '@backstage/integration';\nimport {\n createTemplateAction,\n fetchContents,\n} 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';\nimport { examples } from './confluenceToMarkdown.examples';\nimport { UrlReaderService } from '@backstage/backend-plugin-api';\n\n/**\n * @public\n */\n\nexport const createConfluenceToMarkdownAction = (options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n config: Config;\n}) => {\n const { config, reader, integrations } = options;\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 description: 'Transforms Confluence content to Markdown',\n examples,\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 const repoFileDir = `${dirPath}/${parsedRepoUrl.filepath}`;\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 await fetchContents({\n reader,\n integrations,\n baseUrl: ctx.templateInfo?.baseUrl,\n fetchUrl: `https://${parsedRepoUrl.resource}/${parsedRepoUrl.owner}/${parsedRepoUrl.name}`,\n outputPath: ctx.workspacePath,\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  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":["createTemplateAction","examples","getConfluenceConfig","parseGitUrl","fetchContents","createConfluenceVariables","fetchConfluence","InputError","fs","getAndWriteAttachments","readFileAsString","YAML","ConflictError","NodeHtmlMarkdown"],"mappings":";;;;;;;;;;;;;;;;;AAyCa,MAAA,gCAAA,GAAmC,CAAC,OAI3C,KAAA;AACJ,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAQ,EAAA,YAAA,EAAiB,GAAA,OAAA;AAKzC,EAAA,OAAOA,yCAGJ,CAAA;AAAA,IACD,EAAI,EAAA,+BAAA;AAAA,IACJ,WAAa,EAAA,2CAAA;AAAA,cACbC,sCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,UAAY,EAAA;AAAA,UACV,cAAgB,EAAA;AAAA,YACd,IAAM,EAAA,OAAA;AAAA,YACN,KAAO,EAAA,gBAAA;AAAA,YACP,WACE,EAAA,4NAAA;AAAA,YACF,KAAO,EAAA;AAAA,cACL,IAAM,EAAA,QAAA;AAAA,cACN,OAAS,EAAA;AAAA;AACX,WACF;AAAA,UACA,OAAS,EAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,YACN,KAAO,EAAA,iBAAA;AAAA,YACP,WACE,EAAA;AAAA;AACJ;AACF;AACF,KACF;AAAA,IACA,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAM,MAAA,gBAAA,GAAmBC,4BAAoB,MAAM,CAAA;AACnD,MAAA,MAAM,EAA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AAAA;AAGF,MAAI,GAAA,CAAA,MAAA,CAAO,MAAQ,EAAA,aAAA,CAAc,IAAI,CAAA;AACrC,MAAI,GAAA,CAAA,MAAA,CAAO,OAAS,EAAA,aAAA,CAAc,KAAK,CAAA;AAAA;AACzC,GACD,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"confluenceToMarkdown.cjs.js","sources":["../../../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 { ScmIntegrations } from '@backstage/integration';\nimport {\n createTemplateAction,\n fetchContents,\n} 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';\nimport { examples } from './confluenceToMarkdown.examples';\nimport { UrlReaderService } from '@backstage/backend-plugin-api';\n\n/**\n * @public\n */\n\nexport const createConfluenceToMarkdownAction = (options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n config: Config;\n}) => {\n const { config, reader, integrations } = options;\n type Obj = {\n [key: string]: string;\n };\n\n return createTemplateAction({\n id: 'confluence:transform:markdown',\n description: 'Transforms Confluence content to Markdown',\n examples,\n schema: {\n input: {\n confluenceUrls: z =>\n z.array(z.string(), {\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 }),\n repoUrl: z =>\n z.string({\n description:\n 'mkdocs.yml file location inside the github repo you want to store the document',\n }),\n },\n output: {\n repo: z =>\n z\n .string({\n description: 'Repository name',\n })\n .optional(),\n owner: z =>\n z\n .string({\n description: 'Repository owner',\n })\n .optional(),\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 const repoFileDir = `${dirPath}/${parsedRepoUrl.filepath}`;\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 await fetchContents({\n reader,\n integrations,\n baseUrl: ctx.templateInfo?.baseUrl,\n fetchUrl: `https://${parsedRepoUrl.resource}/${parsedRepoUrl.owner}/${parsedRepoUrl.name}`,\n outputPath: ctx.workspacePath,\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  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":["createTemplateAction","examples","getConfluenceConfig","parseGitUrl","fetchContents","createConfluenceVariables","fetchConfluence","InputError","fs","getAndWriteAttachments","readFileAsString","YAML","ConflictError","NodeHtmlMarkdown"],"mappings":";;;;;;;;;;;;;;;;;AAyCa,MAAA,gCAAA,GAAmC,CAAC,OAI3C,KAAA;AACJ,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAQ,EAAA,YAAA,EAAiB,GAAA,OAAA;AAKzC,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAI,EAAA,+BAAA;AAAA,IACJ,WAAa,EAAA,2CAAA;AAAA,cACbC,sCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,gBAAgB,CACd,CAAA,KAAA,CAAA,CAAE,KAAM,CAAA,CAAA,CAAE,QAAU,EAAA;AAAA,UAClB,WACE,EAAA;AAAA,SACH,CAAA;AAAA,QACH,OAAA,EAAS,CACP,CAAA,KAAA,CAAA,CAAE,MAAO,CAAA;AAAA,UACP,WACE,EAAA;AAAA,SACH;AAAA,OACL;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,IAAA,EAAM,CACJ,CAAA,KAAA,CAAA,CACG,MAAO,CAAA;AAAA,UACN,WAAa,EAAA;AAAA,SACd,EACA,QAAS,EAAA;AAAA,QACd,KAAA,EAAO,CACL,CAAA,KAAA,CAAA,CACG,MAAO,CAAA;AAAA,UACN,WAAa,EAAA;AAAA,SACd,EACA,QAAS;AAAA;AAChB,KACF;AAAA,IACA,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAM,MAAA,gBAAA,GAAmBC,4BAAoB,MAAM,CAAA;AACnD,MAAA,MAAM,EAAE,cAAA,EAAgB,OAAQ,EAAA,GAAI,GAAI,CAAA,KAAA;AACxC,MAAM,MAAA,aAAA,GAAgBC,6BAAY,OAAO,CAAA;AACzC,MAAM,MAAA,gBAAA,GAAmB,cAAc,QAAS,CAAA,SAAA;AAAA,QAC9C,CAAA;AAAA,QACA,aAAc,CAA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ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as _backstage_plugin_scaffolder_node from '@backstage/plugin-scaffolder-node';
|
|
2
|
-
import * as _backstage_types from '@backstage/types';
|
|
3
2
|
import { Config } from '@backstage/config';
|
|
4
3
|
import { ScmIntegrations } from '@backstage/integration';
|
|
5
4
|
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
@@ -15,7 +14,10 @@ declare const createConfluenceToMarkdownAction: (options: {
|
|
|
15
14
|
}) => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
16
15
|
confluenceUrls: string[];
|
|
17
16
|
repoUrl: string;
|
|
18
|
-
},
|
|
17
|
+
}, {
|
|
18
|
+
repo?: string | undefined;
|
|
19
|
+
owner?: string | undefined;
|
|
20
|
+
}, "v2">;
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* @public
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-scaffolder-backend-module-confluence-to-markdown",
|
|
3
|
-
"version": "0.3.10-next.
|
|
3
|
+
"version": "0.3.10-next.2",
|
|
4
4
|
"description": "The confluence-to-markdown module for @backstage/plugin-scaffolder-backend",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -53,20 +53,20 @@
|
|
|
53
53
|
"test": "backstage-cli package test"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@backstage/backend-plugin-api": "1.4.0-next.
|
|
56
|
+
"@backstage/backend-plugin-api": "1.4.0-next.1",
|
|
57
57
|
"@backstage/config": "1.3.2",
|
|
58
58
|
"@backstage/errors": "1.2.7",
|
|
59
59
|
"@backstage/integration": "1.17.0",
|
|
60
|
-
"@backstage/plugin-scaffolder-node": "0.
|
|
60
|
+
"@backstage/plugin-scaffolder-node": "0.9.0-next.2",
|
|
61
61
|
"fs-extra": "^11.2.0",
|
|
62
62
|
"git-url-parse": "^15.0.0",
|
|
63
63
|
"node-html-markdown": "^1.3.0",
|
|
64
64
|
"yaml": "^2.0.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@backstage/backend-test-utils": "1.6.0-next.
|
|
68
|
-
"@backstage/cli": "0.
|
|
69
|
-
"@backstage/plugin-scaffolder-node-test-utils": "0.
|
|
67
|
+
"@backstage/backend-test-utils": "1.6.0-next.2",
|
|
68
|
+
"@backstage/cli": "0.33.0-next.1",
|
|
69
|
+
"@backstage/plugin-scaffolder-node-test-utils": "0.3.0-next.2",
|
|
70
70
|
"msw": "^1.0.0"
|
|
71
71
|
},
|
|
72
72
|
"configSchema": "config.d.ts"
|