@techdocs/cli 1.3.3-next.0 → 1.4.0-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.
Files changed (63) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cjs/index/{PublisherConfig-f679e718.cjs.js → PublisherConfig-9dfc07ee.cjs.js} +3 -2
  3. package/dist/cjs/index/{PublisherConfig-f679e718.cjs.js.map → PublisherConfig-9dfc07ee.cjs.js.map} +1 -1
  4. package/dist/cjs/index/{generate-8f4ae280.cjs.js → generate-8722d4c2.cjs.js} +5 -4
  5. package/dist/cjs/index/generate-8722d4c2.cjs.js.map +1 -0
  6. package/dist/cjs/index/{migrate-20cb2ea3.cjs.js → migrate-5312e76c.cjs.js} +5 -3
  7. package/dist/cjs/index/{migrate-20cb2ea3.cjs.js.map → migrate-5312e76c.cjs.js.map} +1 -1
  8. package/dist/cjs/index/{mkdocs-9fabcb0c.cjs.js → mkdocs-b897f254.cjs.js} +4 -2
  9. package/dist/cjs/index/{mkdocs-9fabcb0c.cjs.js.map → mkdocs-b897f254.cjs.js.map} +1 -1
  10. package/dist/cjs/index/{publish-7e1bb507.cjs.js → publish-f0f203ef.cjs.js} +5 -3
  11. package/dist/cjs/index/{publish-7e1bb507.cjs.js.map → publish-f0f203ef.cjs.js.map} +1 -1
  12. package/dist/cjs/index/{serve-aea8398a.cjs.js → serve-8c722cc8.cjs.js} +4 -2
  13. package/dist/cjs/index/{serve-aea8398a.cjs.js.map → serve-8c722cc8.cjs.js.map} +1 -1
  14. package/dist/cjs/index/{utility-8be2be15.cjs.js → utility-2edd5bff.cjs.js} +16 -1
  15. package/dist/cjs/index/utility-2edd5bff.cjs.js.map +1 -0
  16. package/dist/embedded-app/.config-schema.json +8 -0
  17. package/dist/embedded-app/index.html +1 -1
  18. package/dist/embedded-app/static/1032.90746959.chunk.js +3 -0
  19. package/dist/embedded-app/static/1032.90746959.chunk.js.map +1 -0
  20. package/dist/embedded-app/static/{1105.6191ca0a.chunk.js → 1105.0c932be4.chunk.js} +1 -1
  21. package/dist/embedded-app/static/{1105.6191ca0a.chunk.js.map → 1105.0c932be4.chunk.js.map} +1 -1
  22. package/dist/embedded-app/static/{184.26a4caf6.chunk.js → 184.0de82ef1.chunk.js} +1 -1
  23. package/dist/embedded-app/static/{184.26a4caf6.chunk.js.map → 184.0de82ef1.chunk.js.map} +1 -1
  24. package/dist/embedded-app/static/{2440.184525b4.chunk.js → 2440.0219755d.chunk.js} +1 -1
  25. package/dist/embedded-app/static/{2440.184525b4.chunk.js.map → 2440.0219755d.chunk.js.map} +1 -1
  26. package/dist/embedded-app/static/{5458.68e9cdc0.chunk.js → 5458.36bd7281.chunk.js} +1 -1
  27. package/dist/embedded-app/static/{5458.68e9cdc0.chunk.js.map → 5458.36bd7281.chunk.js.map} +1 -1
  28. package/dist/embedded-app/static/{732.e1699a4c.chunk.js → 732.b3a19fae.chunk.js} +1 -1
  29. package/dist/embedded-app/static/{732.e1699a4c.chunk.js.map → 732.b3a19fae.chunk.js.map} +1 -1
  30. package/dist/embedded-app/static/{7560.93e152cb.chunk.js → 7560.b6001518.chunk.js} +1 -1
  31. package/dist/embedded-app/static/{7560.93e152cb.chunk.js.map → 7560.b6001518.chunk.js.map} +1 -1
  32. package/dist/embedded-app/static/7670.8383e359.chunk.js +3 -0
  33. package/dist/embedded-app/static/7670.8383e359.chunk.js.map +1 -0
  34. package/dist/embedded-app/static/7750.c29731fc.chunk.js +8 -0
  35. package/dist/embedded-app/static/7750.c29731fc.chunk.js.map +1 -0
  36. package/dist/embedded-app/static/{9323.d3b0b6b6.chunk.js → 9323.f715e2ef.chunk.js} +1 -1
  37. package/dist/embedded-app/static/{9323.d3b0b6b6.chunk.js.map → 9323.f715e2ef.chunk.js.map} +1 -1
  38. package/dist/embedded-app/static/9545.12d478b4.chunk.js +3 -0
  39. package/dist/embedded-app/static/{1032.91b320eb.chunk.js.map → 9545.12d478b4.chunk.js.map} +1 -1
  40. package/dist/embedded-app/static/{9770.a743fc85.chunk.js → 9770.94e79bff.chunk.js} +1 -1
  41. package/dist/embedded-app/static/{9770.a743fc85.chunk.js.map → 9770.94e79bff.chunk.js.map} +1 -1
  42. package/dist/embedded-app/static/main.e99a7512.js +503 -0
  43. package/dist/embedded-app/static/main.e99a7512.js.map +1 -0
  44. package/dist/embedded-app/static/{runtime.ca2552f1.js → runtime.e99a7512.js} +2 -2
  45. package/dist/embedded-app/static/{runtime.ca2552f1.js.map → runtime.e99a7512.js.map} +1 -1
  46. package/dist/embedded-app/static/vendor.e99a7512.js +270 -0
  47. package/dist/embedded-app/static/vendor.e99a7512.js.map +1 -0
  48. package/dist/index.cjs.js +9 -6
  49. package/dist/index.cjs.js.map +1 -1
  50. package/package.json +7 -7
  51. package/dist/cjs/index/generate-8f4ae280.cjs.js.map +0 -1
  52. package/dist/cjs/index/utility-8be2be15.cjs.js.map +0 -1
  53. package/dist/embedded-app/static/1032.91b320eb.chunk.js +0 -3
  54. package/dist/embedded-app/static/7670.433cf15c.chunk.js +0 -3
  55. package/dist/embedded-app/static/7670.433cf15c.chunk.js.map +0 -1
  56. package/dist/embedded-app/static/7750.90d0b9bd.chunk.js +0 -8
  57. package/dist/embedded-app/static/7750.90d0b9bd.chunk.js.map +0 -1
  58. package/dist/embedded-app/static/9545.27f02c72.chunk.js +0 -3
  59. package/dist/embedded-app/static/9545.27f02c72.chunk.js.map +0 -1
  60. package/dist/embedded-app/static/main.ca2552f1.js +0 -503
  61. package/dist/embedded-app/static/main.ca2552f1.js.map +0 -1
  62. package/dist/embedded-app/static/vendor.ca2552f1.js +0 -270
  63. package/dist/embedded-app/static/vendor.ca2552f1.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @techdocs/cli
2
2
 
3
+ ## 1.4.0-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/plugin-techdocs-node@1.6.0-next.2
9
+ - @backstage/backend-common@0.18.3-next.2
10
+ - @backstage/config@1.0.7-next.0
11
+
12
+ ## 1.4.0-next.1
13
+
14
+ ### Minor Changes
15
+
16
+ - 8e465ce52e2: Running `@techdocs/cli generate` with the `--verbose` flag will now print the mkdocs output.
17
+ - ea2bbef1b16: Added support for an HTTPS proxy for techdocs AWS S3 requests
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies
22
+ - @backstage/plugin-techdocs-node@1.6.0-next.1
23
+ - @backstage/backend-common@0.18.3-next.1
24
+ - @backstage/cli-common@0.1.12-next.0
25
+ - @backstage/config@1.0.7-next.0
26
+ - @backstage/catalog-model@1.2.1-next.1
27
+
3
28
  ## 1.3.3-next.0
4
29
 
5
30
  ### Patch Changes
@@ -49,7 +49,8 @@ const _PublisherConfig = class {
49
49
  ...opts.awsRoleArn && { credentials: { roleArn: opts.awsRoleArn } },
50
50
  ...opts.awsEndpoint && { endpoint: opts.awsEndpoint },
51
51
  ...opts.awsS3ForcePathStyle && { s3ForcePathStyle: true },
52
- ...opts.awsS3sse && { sse: opts.awsS3sse }
52
+ ...opts.awsS3sse && { sse: opts.awsS3sse },
53
+ ...opts.awsProxy && { httpsProxy: opts.awsProxy }
53
54
  }
54
55
  };
55
56
  }
@@ -130,4 +131,4 @@ PublisherConfig.configFactories = {
130
131
  };
131
132
 
132
133
  exports.PublisherConfig = PublisherConfig;
133
- //# sourceMappingURL=PublisherConfig-f679e718.cjs.js.map
134
+ //# sourceMappingURL=PublisherConfig-9dfc07ee.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PublisherConfig-f679e718.cjs.js","sources":["../../../src/lib/PublisherConfig.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { ConfigReader } from '@backstage/config';\nimport { OptionValues } from 'commander';\n\ntype Publisher = keyof (typeof PublisherConfig)['configFactories'];\ntype PublisherConfiguration = {\n [p in Publisher]?: any;\n} & {\n type: Publisher;\n};\n\n/**\n * Helper when working with publisher-related configurations.\n */\nexport class PublisherConfig {\n /**\n * Maps publisher-specific config keys to config getters.\n */\n private static configFactories = {\n awsS3: PublisherConfig.getValidAwsS3Config,\n azureBlobStorage: PublisherConfig.getValidAzureConfig,\n googleGcs: PublisherConfig.getValidGoogleGcsConfig,\n openStackSwift: PublisherConfig.getValidOpenStackSwiftConfig,\n };\n\n /**\n * Returns Backstage config suitable for use when instantiating a Publisher. If\n * there are any missing or invalid options provided, an error is thrown.\n *\n * Note: This assumes that proper credentials are set in Environment\n * variables for the respective GCS/AWS clients to work.\n */\n static getValidConfig(opts: OptionValues): ConfigReader {\n const publisherType = opts.publisherType;\n\n if (!PublisherConfig.isKnownPublisher(publisherType)) {\n throw new Error(`Unknown publisher type ${opts.publisherType}`);\n }\n\n return new ConfigReader({\n // This backend config is not used at all. Just something needed a create a mock discovery instance.\n backend: {\n baseUrl: 'http://localhost:7007',\n listen: {\n port: 7007,\n },\n },\n techdocs: {\n publisher: PublisherConfig.configFactories[publisherType](opts),\n legacyUseCaseSensitiveTripletPaths:\n opts.legacyUseCaseSensitiveTripletPaths,\n },\n });\n }\n\n /**\n * Typeguard to ensure the publisher has a known config getter.\n */\n private static isKnownPublisher(\n type: string,\n ): type is keyof (typeof PublisherConfig)['configFactories'] {\n return PublisherConfig.configFactories.hasOwnProperty(type);\n }\n\n /**\n * Retrieve valid AWS S3 configuration based on the command.\n */\n private static getValidAwsS3Config(\n opts: OptionValues,\n ): PublisherConfiguration {\n return {\n type: 'awsS3',\n awsS3: {\n bucketName: opts.storageName,\n ...(opts.awsBucketRootPath && {\n bucketRootPath: opts.awsBucketRootPath,\n }),\n ...(opts.awsRoleArn && { credentials: { roleArn: opts.awsRoleArn } }),\n ...(opts.awsEndpoint && { endpoint: opts.awsEndpoint }),\n ...(opts.awsS3ForcePathStyle && { s3ForcePathStyle: true }),\n ...(opts.awsS3sse && { sse: opts.awsS3sse }),\n },\n };\n }\n\n /**\n * Retrieve valid Azure Blob Storage configuration based on the command.\n */\n private static getValidAzureConfig(\n opts: OptionValues,\n ): PublisherConfiguration {\n if (!opts.azureAccountName) {\n throw new Error(\n `azureBlobStorage requires --azureAccountName to be specified`,\n );\n }\n\n return {\n type: 'azureBlobStorage',\n azureBlobStorage: {\n containerName: opts.storageName,\n credentials: {\n accountName: opts.azureAccountName,\n accountKey: opts.azureAccountKey,\n },\n },\n };\n }\n\n /**\n * Retrieve valid GCS configuration based on the command.\n */\n private static getValidGoogleGcsConfig(\n opts: OptionValues,\n ): PublisherConfiguration {\n return {\n type: 'googleGcs',\n googleGcs: {\n bucketName: opts.storageName,\n ...(opts.gcsBucketRootPath && {\n bucketRootPath: opts.gcsBucketRootPath,\n }),\n },\n };\n }\n\n /**\n * Retrieves valid OpenStack Swift configuration based on the command.\n */\n private static getValidOpenStackSwiftConfig(\n opts: OptionValues,\n ): PublisherConfiguration {\n const missingParams = [\n 'osCredentialId',\n 'osSecret',\n 'osAuthUrl',\n 'osSwiftUrl',\n ].filter((param: string) => !opts[param]);\n\n if (missingParams.length) {\n throw new Error(\n `openStackSwift requires the following params to be specified: ${missingParams.join(\n ', ',\n )}`,\n );\n }\n\n return {\n type: 'openStackSwift',\n openStackSwift: {\n containerName: opts.storageName,\n credentials: {\n id: opts.osCredentialId,\n secret: opts.osSecret,\n },\n authUrl: opts.osAuthUrl,\n swiftUrl: opts.osSwiftUrl,\n },\n };\n }\n}\n"],"names":["ConfigReader"],"mappings":";;;;AA6BO,MAAM,mBAAN,MAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkB3B,OAAO,eAAe,IAAkC,EAAA;AACt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ACF,CAAA;AAAA,KACF;AAEA,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,gBAAA;AAAA,MACN,cAAgB,EAAA;AAAA,QACd,eAAe,IAAK,CAAA,WAAA;AAAA,QACpB,WAAa,EAAA;AAAA,UACX,IAAI,IAAK,CAAA,cAAA;AAAA,UACT,QAAQ,IAAK,CAAA,QAAA;AAAA,SACf;AAAA,QACA,SAAS,IAAK,CAAA,SAAA;AAAA,QACd,UAAU,IAAK,CAAA,UAAA;AAAA,OACjB;AAAA,KACF,CAAA;AAAA,GACF;AACF,CAAA,CAAA;AAlJO,IAAM,eAAN,GAAA,iBAAA;AAAA;AAAA;AAAA;AAAM,eAAA,CAII,eAAkB,GAAA;AAAA,EAC/B,OAAO,gBAAgB,CAAA,mBAAA;AAAA,EACvB,kBAAkB,gBAAgB,CAAA,mBAAA;AAAA,EAClC,WAAW,gBAAgB,CAAA,uBAAA;AAAA,EAC3B,gBAAgB,gBAAgB,CAAA,4BAAA;AAClC,CAAA;;;;"}
1
+ {"version":3,"file":"PublisherConfig-9dfc07ee.cjs.js","sources":["../../../src/lib/PublisherConfig.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { ConfigReader } from '@backstage/config';\nimport { OptionValues } from 'commander';\n\ntype Publisher = keyof (typeof PublisherConfig)['configFactories'];\ntype PublisherConfiguration = {\n [p in Publisher]?: any;\n} & {\n type: Publisher;\n};\n\n/**\n * Helper when working with publisher-related configurations.\n */\nexport class PublisherConfig {\n /**\n * Maps publisher-specific config keys to config getters.\n */\n private static configFactories = {\n awsS3: PublisherConfig.getValidAwsS3Config,\n azureBlobStorage: PublisherConfig.getValidAzureConfig,\n googleGcs: PublisherConfig.getValidGoogleGcsConfig,\n openStackSwift: PublisherConfig.getValidOpenStackSwiftConfig,\n };\n\n /**\n * Returns Backstage config suitable for use when instantiating a Publisher. If\n * there are any missing or invalid options provided, an error is thrown.\n *\n * Note: This assumes that proper credentials are set in Environment\n * variables for the respective GCS/AWS clients to work.\n */\n static getValidConfig(opts: OptionValues): ConfigReader {\n const publisherType = opts.publisherType;\n\n if (!PublisherConfig.isKnownPublisher(publisherType)) {\n throw new Error(`Unknown publisher type ${opts.publisherType}`);\n }\n\n return new ConfigReader({\n // This backend config is not used at all. Just something needed a create a mock discovery instance.\n backend: {\n baseUrl: 'http://localhost:7007',\n listen: {\n port: 7007,\n },\n },\n techdocs: {\n publisher: PublisherConfig.configFactories[publisherType](opts),\n legacyUseCaseSensitiveTripletPaths:\n opts.legacyUseCaseSensitiveTripletPaths,\n },\n });\n }\n\n /**\n * Typeguard to ensure the publisher has a known config getter.\n */\n private static isKnownPublisher(\n type: string,\n ): type is keyof (typeof PublisherConfig)['configFactories'] {\n return PublisherConfig.configFactories.hasOwnProperty(type);\n }\n\n /**\n * Retrieve valid AWS S3 configuration based on the command.\n */\n private static getValidAwsS3Config(\n opts: OptionValues,\n ): PublisherConfiguration {\n return {\n type: 'awsS3',\n awsS3: {\n bucketName: opts.storageName,\n ...(opts.awsBucketRootPath && {\n bucketRootPath: opts.awsBucketRootPath,\n }),\n ...(opts.awsRoleArn && { credentials: { roleArn: opts.awsRoleArn } }),\n ...(opts.awsEndpoint && { endpoint: opts.awsEndpoint }),\n ...(opts.awsS3ForcePathStyle && { s3ForcePathStyle: true }),\n ...(opts.awsS3sse && { sse: opts.awsS3sse }),\n ...(opts.awsProxy && { httpsProxy: opts.awsProxy }),\n },\n };\n }\n\n /**\n * Retrieve valid Azure Blob Storage configuration based on the command.\n */\n private static getValidAzureConfig(\n opts: OptionValues,\n ): PublisherConfiguration {\n if (!opts.azureAccountName) {\n throw new Error(\n `azureBlobStorage requires --azureAccountName to be specified`,\n );\n }\n\n return {\n type: 'azureBlobStorage',\n azureBlobStorage: {\n containerName: opts.storageName,\n credentials: {\n accountName: opts.azureAccountName,\n accountKey: opts.azureAccountKey,\n },\n },\n };\n }\n\n /**\n * Retrieve valid GCS configuration based on the command.\n */\n private static getValidGoogleGcsConfig(\n opts: OptionValues,\n ): PublisherConfiguration {\n return {\n type: 'googleGcs',\n googleGcs: {\n bucketName: opts.storageName,\n ...(opts.gcsBucketRootPath && {\n bucketRootPath: opts.gcsBucketRootPath,\n }),\n },\n };\n }\n\n /**\n * Retrieves valid OpenStack Swift configuration based on the command.\n */\n private static getValidOpenStackSwiftConfig(\n opts: OptionValues,\n ): PublisherConfiguration {\n const missingParams = [\n 'osCredentialId',\n 'osSecret',\n 'osAuthUrl',\n 'osSwiftUrl',\n ].filter((param: string) => !opts[param]);\n\n if (missingParams.length) {\n throw new Error(\n `openStackSwift requires the following params to be specified: ${missingParams.join(\n ', ',\n )}`,\n );\n }\n\n return {\n type: 'openStackSwift',\n openStackSwift: {\n containerName: opts.storageName,\n credentials: {\n id: opts.osCredentialId,\n secret: opts.osSecret,\n },\n authUrl: opts.osAuthUrl,\n swiftUrl: opts.osSwiftUrl,\n },\n };\n }\n}\n"],"names":["ConfigReader"],"mappings":";;;;AA6BO,MAAM,mBAAN,MAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkB3B,OAAO,eAAe,IAAkC,EAAA;AACtD,IAAA,MAAM,gBAAgB,IAAK,CAAA,aAAA,CAAA;AAE3B,IAAA,IAAI,CAAC,gBAAA,CAAgB,gBAAiB,CAAA,aAAa,CAAG,EAAA;AACpD,MAAA,MAAM,IAAI,KAAA,CAAM,CAA0B,uBAAA,EAAA,IAAA,CAAK,aAAe,CAAA,CAAA,CAAA,CAAA;AAAA,KAChE;AAEA,IAAA,OAAO,IAAIA,mBAAa,CAAA;AA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UACT,QAAQ,IAAK,CAAA,QAAA;AAAA,SACf;AAAA,QACA,SAAS,IAAK,CAAA,SAAA;AAAA,QACd,UAAU,IAAK,CAAA,UAAA;AAAA,OACjB;AAAA,KACF,CAAA;AAAA,GACF;AACF,CAAA,CAAA;AAnJO,IAAM,eAAN,GAAA,iBAAA;AAAA;AAAA;AAAA;AAAM,eAAA,CAII,eAAkB,GAAA;AAAA,EAC/B,OAAO,gBAAgB,CAAA,mBAAA;AAAA,EACvB,kBAAkB,gBAAgB,CAAA,mBAAA;AAAA,EAClC,WAAW,gBAAgB,CAAA,uBAAA;AAAA,EAC3B,gBAAgB,gBAAgB,CAAA,4BAAA;AAClC,CAAA;;;;"}
@@ -6,9 +6,10 @@ var Docker = require('dockerode');
6
6
  var pluginTechdocsNode = require('@backstage/plugin-techdocs-node');
7
7
  var backendCommon = require('@backstage/backend-common');
8
8
  var config = require('@backstage/config');
9
- var utility = require('./utility-8be2be15.cjs.js');
10
- var process$1 = require('process');
9
+ var utility = require('./utility-2edd5bff.cjs.js');
11
10
  require('winston');
11
+ require('stream');
12
+ require('process');
12
13
 
13
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
15
 
@@ -71,7 +72,7 @@ async function generate(opts) {
71
72
  } : {},
72
73
  logger,
73
74
  etag: opts.etag,
74
- ...process.env.LOG_LEVEL === "debug" ? { logStream: process$1.stdout } : {},
75
+ logStream: utility.getLogStream(logger),
75
76
  siteOptions: { name: opts.siteName }
76
77
  });
77
78
  if (configIsTemporary) {
@@ -83,4 +84,4 @@ async function generate(opts) {
83
84
  }
84
85
 
85
86
  exports["default"] = generate;
86
- //# sourceMappingURL=generate-8f4ae280.cjs.js.map
87
+ //# sourceMappingURL=generate-8722d4c2.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-8722d4c2.cjs.js","sources":["../../../src/commands/generate/generate.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { resolve } from 'path';\nimport { OptionValues } from 'commander';\nimport fs from 'fs-extra';\nimport Docker from 'dockerode';\nimport {\n TechdocsGenerator,\n ParsedLocationAnnotation,\n getMkdocsYml,\n} from '@backstage/plugin-techdocs-node';\nimport {\n ContainerRunner,\n DockerContainerRunner,\n} from '@backstage/backend-common';\nimport { ConfigReader } from '@backstage/config';\nimport {\n convertTechDocsRefToLocationAnnotation,\n createLogger,\n getLogStream,\n} from '../../lib/utility';\n\nexport default async function generate(opts: OptionValues) {\n // Use techdocs-node package to generate docs. Keep consistency between Backstage and CI generating docs.\n // Docs can be prepared using actions/checkout or git clone, or similar paradigms on CI. The TechDocs CI workflow\n // will run on the CI pipeline containing the documentation files.\n\n const logger = createLogger({ verbose: opts.verbose });\n\n const sourceDir = resolve(opts.sourceDir);\n const outputDir = resolve(opts.outputDir);\n const omitTechdocsCorePlugin = opts.omitTechdocsCoreMkdocsPlugin;\n const dockerImage = opts.dockerImage;\n const pullImage = opts.pull;\n const legacyCopyReadmeMdToIndexMd = opts.legacyCopyReadmeMdToIndexMd;\n\n logger.info(`Using source dir ${sourceDir}`);\n logger.info(`Will output generated files in ${outputDir}`);\n\n logger.verbose('Creating output directory if it does not exist.');\n\n await fs.ensureDir(outputDir);\n\n const { path: mkdocsYmlPath, configIsTemporary } = await getMkdocsYml(\n sourceDir,\n );\n\n const config = new ConfigReader({\n techdocs: {\n generator: {\n runIn: opts.docker ? 'docker' : 'local',\n dockerImage,\n pullImage,\n mkdocs: {\n legacyCopyReadmeMdToIndexMd,\n omitTechdocsCorePlugin,\n },\n },\n },\n });\n\n // Docker client (conditionally) used by the generators, based on techdocs.generators config.\n let containerRunner: ContainerRunner | undefined;\n\n if (opts.docker) {\n const dockerClient = new Docker();\n containerRunner = new DockerContainerRunner({ dockerClient });\n }\n\n let parsedLocationAnnotation = {} as ParsedLocationAnnotation;\n if (opts.techdocsRef) {\n try {\n parsedLocationAnnotation = convertTechDocsRefToLocationAnnotation(\n opts.techdocsRef,\n );\n } catch (err) {\n logger.error(err.message);\n }\n }\n\n // Generate docs using @backstage/plugin-techdocs-node\n const techdocsGenerator = await TechdocsGenerator.fromConfig(config, {\n logger,\n containerRunner,\n });\n\n logger.info('Generating documentation...');\n\n await techdocsGenerator.run({\n inputDir: sourceDir,\n outputDir,\n ...(opts.techdocsRef\n ? {\n parsedLocationAnnotation,\n }\n : {}),\n logger,\n etag: opts.etag,\n logStream: getLogStream(logger),\n siteOptions: { name: opts.siteName },\n });\n\n if (configIsTemporary) {\n process.on('exit', async () => {\n fs.rmSync(mkdocsYmlPath, {});\n });\n }\n\n logger.info('Done!');\n}\n"],"names":["createLogger","resolve","fs","getMkdocsYml","config","ConfigReader","Docker","DockerContainerRunner","convertTechDocsRefToLocationAnnotation","TechdocsGenerator","getLogStream"],"mappings":";;;;;;;;;;;;;;;;;;AAoCA,eAA8B,SAAS,IAAoB,EAAA;AAKzD,EAAA,MAAM,SAASA,oBAAa,CAAA,EAAE,OAAS,EAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AAErD,EAAM,MAAA,SAAA,GAAYC,YAAQ,CAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AACxC,EAAM,MAAA,SAAA,GAAYA,YAAQ,CAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AACxC,EAAA,MAAM,yBAAyB,IAAK,CAAA,4BAAA,CAAA;AACpC,EAAA,MAAM,cAAc,IAAK,CAAA,WAAA,CAAA;AACzB,EAAA,MAAM,YAAY,IAAK,CAAA,IAAA,CAAA;AACvB,EAAA,MAAM,8BAA8B,IAAK,CAAA,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AMC,oCAAkB,CAAA,UAAA,CAAWL,QAAQ,EAAA;AAAA,IACnE,MAAA;AAAA,IACA,eAAA;AAAA,GACD,CAAA,CAAA;AAED,EAAA,MAAA,CAAO,KAAK,6BAA6B,CAAA,CAAA;AAEzC,EAAA,MAAM,kBAAkB,GAAI,CAAA;AAAA,IAC1B,QAAU,EAAA,SAAA;AAAA,IACV,SAAA;AAAA,IACA,GAAI,KAAK,WACL,GAAA;AAAA,MACE,wBAAA;AAAA,QAEF,EAAC;AAAA,IACL,MAAA;AAAA,IACA,MAAM,IAAK,CAAA,IAAA;AAAA,IACX,SAAA,EAAWM,qBAAa,MAAM,CAAA;AAAA,IAC9B,WAAa,EAAA,EAAE,IAAM,EAAA,IAAA,CAAK,QAAS,EAAA;AAAA,GACpC,CAAA,CAAA;AAED,EAAA,IAAI,iBAAmB,EAAA;AACrB,IAAQ,OAAA,CAAA,EAAA,CAAG,QAAQ,YAAY;AAC7B,MAAGR,sBAAA,CAAA,MAAA,CAAO,aAAe,EAAA,EAAE,CAAA,CAAA;AAAA,KAC5B,CAAA,CAAA;AAAA,GACH;AAEA,EAAA,MAAA,CAAO,KAAK,OAAO,CAAA,CAAA;AACrB;;;;"}
@@ -2,9 +2,11 @@
2
2
 
3
3
  var backendCommon = require('@backstage/backend-common');
4
4
  var pluginTechdocsNode = require('@backstage/plugin-techdocs-node');
5
- var utility = require('./utility-8be2be15.cjs.js');
6
- var PublisherConfig = require('./PublisherConfig-f679e718.cjs.js');
5
+ var utility = require('./utility-2edd5bff.cjs.js');
6
+ var PublisherConfig = require('./PublisherConfig-9dfc07ee.cjs.js');
7
7
  require('winston');
8
+ require('stream');
9
+ require('process');
8
10
  require('@backstage/config');
9
11
 
10
12
  async function migrate(opts) {
@@ -33,4 +35,4 @@ async function migrate(opts) {
33
35
  }
34
36
 
35
37
  exports["default"] = migrate;
36
- //# sourceMappingURL=migrate-20cb2ea3.cjs.js.map
38
+ //# sourceMappingURL=migrate-5312e76c.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrate-20cb2ea3.cjs.js","sources":["../../../src/commands/migrate/migrate.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { SingleHostDiscovery } from '@backstage/backend-common';\nimport { Publisher } from '@backstage/plugin-techdocs-node';\nimport { OptionValues } from 'commander';\nimport { createLogger } from '../../lib/utility';\nimport { PublisherConfig } from '../../lib/PublisherConfig';\n\nexport default async function migrate(opts: OptionValues) {\n const logger = createLogger({ verbose: opts.verbose });\n\n const config = PublisherConfig.getValidConfig(opts);\n const discovery = SingleHostDiscovery.fromConfig(config);\n const publisher = await Publisher.fromConfig(config, { logger, discovery });\n\n if (!publisher.migrateDocsCase) {\n throw new Error(`Migration not implemented for ${opts.publisherType}`);\n }\n\n // Check that the publisher's underlying storage is ready and available.\n const { isAvailable } = await publisher.getReadiness();\n if (!isAvailable) {\n // Error messages printed in getReadiness() call. This ensures exit code 1.\n throw new Error('');\n }\n\n // Validate and parse migration arguments.\n const removeOriginal = opts.removeOriginal;\n const numericConcurrency = parseInt(opts.concurrency, 10);\n\n if (!Number.isInteger(numericConcurrency) || numericConcurrency <= 0) {\n throw new Error(\n `Concurrency must be a number greater than 1. ${opts.concurrency} provided.`,\n );\n }\n\n await publisher.migrateDocsCase({\n concurrency: numericConcurrency,\n removeOriginal,\n });\n}\n"],"names":["createLogger","PublisherConfig","SingleHostDiscovery","Publisher"],"mappings":";;;;;;;;;AAsBA,eAA8B,QAAQ,IAAoB,EAAA;AACxD,EAAA,MAAM,SAASA,oBAAa,CAAA,EAAE,OAAS,EAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AAErD,EAAM,MAAA,MAAA,GAASC,+BAAgB,CAAA,cAAA,CAAe,IAAI,CAAA,CAAA;AAClD,EAAM,MAAA,SAAA,GAAYC,iCAAoB,CAAA,UAAA,CAAW,MAAM,CAAA,CAAA;AACvD,EAAM,MAAA,SAAA,GAAY,MAAMC,4BAAU,CAAA,UAAA,CAAW,QAAQ,EAAE,MAAA,EAAQ,WAAW,CAAA,CAAA;AAE1E,EAAI,IAAA,CAAC,UAAU,eAAiB,EAAA;AAC9B,IAAA,MAAM,IAAI,KAAA,CAAM,CAAiC,8BAAA,EAAA,IAAA,CAAK,aAAe,CAAA,CAAA,CAAA,CAAA;AAAA,GACvE;AAGA,EAAA,MAAM,EAAE,WAAA,EAAgB,GAAA,MAAM,UAAU,YAAa,EAAA,CAAA;AACrD,EAAA,IAAI,CAAC,WAAa,EAAA;AAEhB,IAAM,MAAA,IAAI,MAAM,EAAE,CAAA,CAAA;AAAA,GACpB;AAGA,EAAA,MAAM,iBAAiB,IAAK,CAAA,cAAA,CAAA;AAC5B,EAAA,MAAM,kBAAqB,GAAA,QAAA,CAAS,IAAK,CAAA,WAAA,EAAa,EAAE,CAAA,CAAA;AAExD,EAAA,IAAI,CAAC,MAAO,CAAA,SAAA,CAAU,kBAAkB,CAAA,IAAK,sBAAsB,CAAG,EAAA;AACpE,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,gDAAgD,IAAK,CAAA,WAAA,CAAA,UAAA,CAAA;AAAA,KACvD,CAAA;AAAA,GACF;AAEA,EAAA,MAAM,UAAU,eAAgB,CAAA;AAAA,IAC9B,WAAa,EAAA,kBAAA;AAAA,IACb,cAAA;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"migrate-5312e76c.cjs.js","sources":["../../../src/commands/migrate/migrate.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { SingleHostDiscovery } from '@backstage/backend-common';\nimport { Publisher } from '@backstage/plugin-techdocs-node';\nimport { OptionValues } from 'commander';\nimport { createLogger } from '../../lib/utility';\nimport { PublisherConfig } from '../../lib/PublisherConfig';\n\nexport default async function migrate(opts: OptionValues) {\n const logger = createLogger({ verbose: opts.verbose });\n\n const config = PublisherConfig.getValidConfig(opts);\n const discovery = SingleHostDiscovery.fromConfig(config);\n const publisher = await Publisher.fromConfig(config, { logger, discovery });\n\n if (!publisher.migrateDocsCase) {\n throw new Error(`Migration not implemented for ${opts.publisherType}`);\n }\n\n // Check that the publisher's underlying storage is ready and available.\n const { isAvailable } = await publisher.getReadiness();\n if (!isAvailable) {\n // Error messages printed in getReadiness() call. This ensures exit code 1.\n throw new Error('');\n }\n\n // Validate and parse migration arguments.\n const removeOriginal = opts.removeOriginal;\n const numericConcurrency = parseInt(opts.concurrency, 10);\n\n if (!Number.isInteger(numericConcurrency) || numericConcurrency <= 0) {\n throw new Error(\n `Concurrency must be a number greater than 1. ${opts.concurrency} provided.`,\n );\n }\n\n await publisher.migrateDocsCase({\n concurrency: numericConcurrency,\n removeOriginal,\n });\n}\n"],"names":["createLogger","PublisherConfig","SingleHostDiscovery","Publisher"],"mappings":";;;;;;;;;;;AAsBA,eAA8B,QAAQ,IAAoB,EAAA;AACxD,EAAA,MAAM,SAASA,oBAAa,CAAA,EAAE,OAAS,EAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AAErD,EAAM,MAAA,MAAA,GAASC,+BAAgB,CAAA,cAAA,CAAe,IAAI,CAAA,CAAA;AAClD,EAAM,MAAA,SAAA,GAAYC,iCAAoB,CAAA,UAAA,CAAW,MAAM,CAAA,CAAA;AACvD,EAAM,MAAA,SAAA,GAAY,MAAMC,4BAAU,CAAA,UAAA,CAAW,QAAQ,EAAE,MAAA,EAAQ,WAAW,CAAA,CAAA;AAE1E,EAAI,IAAA,CAAC,UAAU,eAAiB,EAAA;AAC9B,IAAA,MAAM,IAAI,KAAA,CAAM,CAAiC,8BAAA,EAAA,IAAA,CAAK,aAAe,CAAA,CAAA,CAAA,CAAA;AAAA,GACvE;AAGA,EAAA,MAAM,EAAE,WAAA,EAAgB,GAAA,MAAM,UAAU,YAAa,EAAA,CAAA;AACrD,EAAA,IAAI,CAAC,WAAa,EAAA;AAEhB,IAAM,MAAA,IAAI,MAAM,EAAE,CAAA,CAAA;AAAA,GACpB;AAGA,EAAA,MAAM,iBAAiB,IAAK,CAAA,cAAA,CAAA;AAC5B,EAAA,MAAM,kBAAqB,GAAA,QAAA,CAAS,IAAK,CAAA,WAAA,EAAa,EAAE,CAAA,CAAA;AAExD,EAAA,IAAI,CAAC,MAAO,CAAA,SAAA,CAAU,kBAAkB,CAAA,IAAK,sBAAsB,CAAG,EAAA;AACpE,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,gDAAgD,IAAK,CAAA,WAAA,CAAA,UAAA,CAAA;AAAA,KACvD,CAAA;AAAA,GACF;AAEA,EAAA,MAAM,UAAU,eAAgB,CAAA;AAAA,IAC9B,WAAa,EAAA,kBAAA;AAAA,IACb,cAAA;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
@@ -1,11 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  var openBrowser = require('react-dev-utils/openBrowser');
4
- var utility = require('./utility-8be2be15.cjs.js');
4
+ var utility = require('./utility-2edd5bff.cjs.js');
5
5
  var mkdocsServer = require('./mkdocsServer-db7109fb.cjs.js');
6
6
  var pluginTechdocsNode = require('@backstage/plugin-techdocs-node');
7
7
  var fs = require('fs-extra');
8
8
  require('winston');
9
+ require('stream');
10
+ require('process');
9
11
  require('child_process');
10
12
 
11
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -58,4 +60,4 @@ Starting mkdocs server on ${localAddr}
58
60
  }
59
61
 
60
62
  exports["default"] = serveMkdocs;
61
- //# sourceMappingURL=mkdocs-9fabcb0c.cjs.js.map
63
+ //# sourceMappingURL=mkdocs-b897f254.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mkdocs-9fabcb0c.cjs.js","sources":["../../../src/commands/serve/mkdocs.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { OptionValues } from 'commander';\nimport openBrowser from 'react-dev-utils/openBrowser';\nimport { createLogger } from '../../lib/utility';\nimport { runMkdocsServer } from '../../lib/mkdocsServer';\nimport { LogFunc, waitForSignal } from '../../lib/run';\nimport { getMkdocsYml } from '@backstage/plugin-techdocs-node';\nimport fs from 'fs-extra';\n\nexport default async function serveMkdocs(opts: OptionValues) {\n const logger = createLogger({ verbose: opts.verbose });\n\n const dockerAddr = `http://0.0.0.0:${opts.port}`;\n const localAddr = `http://127.0.0.1:${opts.port}`;\n const expectedDevAddr = opts.docker ? dockerAddr : localAddr;\n\n const { path: mkdocsYmlPath, configIsTemporary } = await getMkdocsYml(\n './',\n opts.siteName,\n );\n\n // We want to open browser only once based on a log.\n let boolOpenBrowserTriggered = false;\n\n const logFunc: LogFunc = data => {\n // Sometimes the lines contain an unnecessary extra new line in between\n const logLines = data.toString().split('\\n');\n const logPrefix = opts.docker ? '[docker/mkdocs]' : '[mkdocs]';\n logLines.forEach(line => {\n if (line === '') {\n return;\n }\n\n // Logs from container is verbose.\n logger.verbose(`${logPrefix} ${line}`);\n\n // When the server has started, open a new browser tab for the user.\n if (\n !boolOpenBrowserTriggered &&\n line.includes(`Serving on ${expectedDevAddr}`)\n ) {\n // Always open the local address, since 0.0.0.0 belongs to docker\n logger.info(`\\nStarting mkdocs server on ${localAddr}\\n`);\n openBrowser(localAddr);\n boolOpenBrowserTriggered = true;\n }\n });\n };\n // mkdocs writes all of its logs to stderr by default, and not stdout.\n // https://github.com/mkdocs/mkdocs/issues/879#issuecomment-203536006\n // Had me questioning this whole implementation for half an hour.\n\n // Commander stores --no-docker in cmd.docker variable\n const childProcess = await runMkdocsServer({\n port: opts.port,\n dockerImage: opts.dockerImage,\n dockerEntrypoint: opts.dockerEntrypoint,\n dockerOptions: opts.dockerOption,\n useDocker: opts.docker,\n stdoutLogFunc: logFunc,\n stderrLogFunc: logFunc,\n });\n\n // Keep waiting for user to cancel the process\n await waitForSignal([childProcess]);\n\n if (configIsTemporary) {\n process.on('exit', async () => {\n fs.rmSync(mkdocsYmlPath, {});\n });\n }\n}\n"],"names":["createLogger","getMkdocsYml","openBrowser","runMkdocsServer","waitForSignal","fs"],"mappings":";;;;;;;;;;;;;;;AAwBA,eAA8B,YAAY,IAAoB,EAAA;AAC5D,EAAA,MAAM,SAASA,oBAAa,CAAA,EAAE,OAAS,EAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AAErD,EAAM,MAAA,UAAA,GAAa,kBAAkB,IAAK,CAAA,IAAA,CAAA,CAAA,CAAA;AAC1C,EAAM,MAAA,SAAA,GAAY,oBAAoB,IAAK,CAAA,IAAA,CAAA,CAAA,CAAA;AAC3C,EAAM,MAAA,eAAA,GAAkB,IAAK,CAAA,MAAA,GAAS,UAAa,GAAA,SAAA,CAAA;AAEnD,EAAA,MAAM,EAAE,IAAA,EAAM,aAAe,EAAA,iBAAA,KAAsB,MAAMC,+BAAA;AAAA,IACvD,IAAA;AAAA,IACA,IAAK,C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AI,iBAAmB,EAAA;AACrB,IAAQ,OAAA,CAAA,EAAA,CAAG,QAAQ,YAAY;AAC7B,MAAGC,sBAAA,CAAA,MAAA,CAAO,aAAe,EAAA,EAAE,CAAA,CAAA;AAAA,KAC5B,CAAA,CAAA;AAAA,GACH;AACF;;;;"}
1
+ {"version":3,"file":"mkdocs-b897f254.cjs.js","sources":["../../../src/commands/serve/mkdocs.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { OptionValues } from 'commander';\nimport openBrowser from 'react-dev-utils/openBrowser';\nimport { createLogger } from '../../lib/utility';\nimport { runMkdocsServer } from '../../lib/mkdocsServer';\nimport { LogFunc, waitForSignal } from '../../lib/run';\nimport { getMkdocsYml } from '@backstage/plugin-techdocs-node';\nimport fs from 'fs-extra';\n\nexport default async function serveMkdocs(opts: OptionValues) {\n const logger = createLogger({ verbose: opts.verbose });\n\n const dockerAddr = `http://0.0.0.0:${opts.port}`;\n const localAddr = `http://127.0.0.1:${opts.port}`;\n const expectedDevAddr = opts.docker ? dockerAddr : localAddr;\n\n const { path: mkdocsYmlPath, configIsTemporary } = await getMkdocsYml(\n './',\n opts.siteName,\n );\n\n // We want to open browser only once based on a log.\n let boolOpenBrowserTriggered = false;\n\n const logFunc: LogFunc = data => {\n // Sometimes the lines contain an unnecessary extra new line in between\n const logLines = data.toString().split('\\n');\n const logPrefix = opts.docker ? '[docker/mkdocs]' : '[mkdocs]';\n logLines.forEach(line => {\n if (line === '') {\n return;\n }\n\n // Logs from container is verbose.\n logger.verbose(`${logPrefix} ${line}`);\n\n // When the server has started, open a new browser tab for the user.\n if (\n !boolOpenBrowserTriggered &&\n line.includes(`Serving on ${expectedDevAddr}`)\n ) {\n // Always open the local address, since 0.0.0.0 belongs to docker\n logger.info(`\\nStarting mkdocs server on ${localAddr}\\n`);\n openBrowser(localAddr);\n boolOpenBrowserTriggered = true;\n }\n });\n };\n // mkdocs writes all of its logs to stderr by default, and not stdout.\n // https://github.com/mkdocs/mkdocs/issues/879#issuecomment-203536006\n // Had me questioning this whole implementation for half an hour.\n\n // Commander stores --no-docker in cmd.docker variable\n const childProcess = await runMkdocsServer({\n port: opts.port,\n dockerImage: opts.dockerImage,\n dockerEntrypoint: opts.dockerEntrypoint,\n dockerOptions: opts.dockerOption,\n useDocker: opts.docker,\n stdoutLogFunc: logFunc,\n stderrLogFunc: logFunc,\n });\n\n // Keep waiting for user to cancel the process\n await waitForSignal([childProcess]);\n\n if (configIsTemporary) {\n process.on('exit', async () => {\n fs.rmSync(mkdocsYmlPath, {});\n });\n }\n}\n"],"names":["createLogger","getMkdocsYml","openBrowser","runMkdocsServer","waitForSignal","fs"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,eAA8B,YAAY,IAAoB,EAAA;AAC5D,EAAA,MAAM,SAASA,oBAAa,CAAA,EAAE,OAAS,EAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AAErD,EAAM,MAAA,UAAA,GAAa,kBAAkB,IAAK,CAAA,IAAA,CAAA,CAAA,CAAA;AAC1C,EAAM,MAAA,SAAA,GAAY,oBAAoB,IAAK,CAAA,IAAA,CAAA,CAAA,CAAA;AAC3C,EAAM,MAAA,eAAA,GAAkB,IAAK,CAAA,MAAA,GAAS,UAAa,GAAA,SAAA,CAAA;AAEnD,EAAA,MAAM,EAAE,IAAA,EAAM,aAAe,EAAA,iBAAA,KAAsB,MAAMC,+BAAA;AAAA,IACvD,IAAA;AAAA,IACA,IAAK,CAAA,QAAA;AAAA,GACP,CAAA;AAGA,EAAA,IAAI,wBAA2B,GAAA,KAAA,CAA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AC7B,MAAGC,sBAAA,CAAA,MAAA,CAAO,aAAe,EAAA,EAAE,CAAA,CAAA;AAAA,KAC5B,CAAA,CAAA;AAAA,GACH;AACF;;;;"}
@@ -1,11 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  var path = require('path');
4
- var utility = require('./utility-8be2be15.cjs.js');
4
+ var utility = require('./utility-2edd5bff.cjs.js');
5
5
  var backendCommon = require('@backstage/backend-common');
6
6
  var pluginTechdocsNode = require('@backstage/plugin-techdocs-node');
7
- var PublisherConfig = require('./PublisherConfig-f679e718.cjs.js');
7
+ var PublisherConfig = require('./PublisherConfig-9dfc07ee.cjs.js');
8
8
  require('winston');
9
+ require('stream');
10
+ require('process');
9
11
  require('@backstage/config');
10
12
 
11
13
  async function publish(opts) {
@@ -31,4 +33,4 @@ async function publish(opts) {
31
33
  }
32
34
 
33
35
  exports["default"] = publish;
34
- //# sourceMappingURL=publish-7e1bb507.cjs.js.map
36
+ //# sourceMappingURL=publish-f0f203ef.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"publish-7e1bb507.cjs.js","sources":["../../../src/commands/publish/publish.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { resolve } from 'path';\nimport { OptionValues } from 'commander';\nimport { createLogger } from '../../lib/utility';\nimport { SingleHostDiscovery } from '@backstage/backend-common';\nimport { Publisher } from '@backstage/plugin-techdocs-node';\nimport { Entity } from '@backstage/catalog-model';\nimport { PublisherConfig } from '../../lib/PublisherConfig';\n\nexport default async function publish(opts: OptionValues): Promise<any> {\n const logger = createLogger({ verbose: opts.verbose });\n\n const config = PublisherConfig.getValidConfig(opts);\n const discovery = SingleHostDiscovery.fromConfig(config);\n const publisher = await Publisher.fromConfig(config, { logger, discovery });\n\n // Check that the publisher's underlying storage is ready and available.\n const { isAvailable } = await publisher.getReadiness();\n if (!isAvailable) {\n // Error messages printed in getReadiness() call. This ensures exit code 1.\n return Promise.reject(new Error(''));\n }\n\n const [namespace, kind, name] = opts.entity.split('/');\n const entity = {\n kind,\n metadata: {\n namespace,\n name,\n },\n } as Entity;\n\n const directory = resolve(opts.directory);\n await publisher.publish({ entity, directory });\n\n return true;\n}\n"],"names":["createLogger","PublisherConfig","SingleHostDiscovery","Publisher","resolve"],"mappings":";;;;;;;;;;AAwBA,eAA8B,QAAQ,IAAkC,EAAA;AACtE,EAAA,MAAM,SAASA,oBAAa,CAAA,EAAE,OAAS,EAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AAErD,EAAM,MAAA,MAAA,GAASC,+BAAgB,CAAA,cAAA,CAAe,IAAI,CAAA,CAAA;AAClD,EAAM,MAAA,SAAA,GAAYC,iCAAoB,CAAA,UAAA,CAAW,MAAM,CAAA,CAAA;AACvD,EAAM,MAAA,SAAA,GAAY,MAAMC,4BAAU,CAAA,UAAA,CAAW,QAAQ,EAAE,MAAA,EAAQ,WAAW,CAAA,CAAA;AAG1E,EAAA,MAAM,EAAE,WAAA,EAAgB,GAAA,MAAM,UAAU,YAAa,EAAA,CAAA;AACrD,EAAA,IAAI,CAAC,WAAa,EAAA;AAEhB,IAAA,OAAO,OAAQ,CAAA,MAAA,CAAO,IAAI,KAAA,CAAM,EAAE,CAAC,CAAA,CAAA;AAAA,GACrC;AAEA,EAAM,MAAA,CAAC,WAAW,IAAM,EAAA,IAAI,IAAI,IAAK,CAAA,MAAA,CAAO,MAAM,GAAG,CAAA,CAAA;AACrD,EAAA,MAAM,MAAS,GAAA;AAAA,IACb,IAAA;AAAA,IACA,QAAU,EAAA;AAAA,MACR,SAAA;AAAA,MACA,IAAA;AAAA,KACF;AAAA,GACF,CAAA;AAEA,EAAM,MAAA,SAAA,GAAYC,YAAQ,CAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AACxC,EAAA,MAAM,SAAU,CAAA,OAAA,CAAQ,EAAE,MAAA,EAAQ,WAAW,CAAA,CAAA;AAE7C,EAAO,OAAA,IAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"publish-f0f203ef.cjs.js","sources":["../../../src/commands/publish/publish.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { resolve } from 'path';\nimport { OptionValues } from 'commander';\nimport { createLogger } from '../../lib/utility';\nimport { SingleHostDiscovery } from '@backstage/backend-common';\nimport { Publisher } from '@backstage/plugin-techdocs-node';\nimport { Entity } from '@backstage/catalog-model';\nimport { PublisherConfig } from '../../lib/PublisherConfig';\n\nexport default async function publish(opts: OptionValues): Promise<any> {\n const logger = createLogger({ verbose: opts.verbose });\n\n const config = PublisherConfig.getValidConfig(opts);\n const discovery = SingleHostDiscovery.fromConfig(config);\n const publisher = await Publisher.fromConfig(config, { logger, discovery });\n\n // Check that the publisher's underlying storage is ready and available.\n const { isAvailable } = await publisher.getReadiness();\n if (!isAvailable) {\n // Error messages printed in getReadiness() call. This ensures exit code 1.\n return Promise.reject(new Error(''));\n }\n\n const [namespace, kind, name] = opts.entity.split('/');\n const entity = {\n kind,\n metadata: {\n namespace,\n name,\n },\n } as Entity;\n\n const directory = resolve(opts.directory);\n await publisher.publish({ entity, directory });\n\n return true;\n}\n"],"names":["createLogger","PublisherConfig","SingleHostDiscovery","Publisher","resolve"],"mappings":";;;;;;;;;;;;AAwBA,eAA8B,QAAQ,IAAkC,EAAA;AACtE,EAAA,MAAM,SAASA,oBAAa,CAAA,EAAE,OAAS,EAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AAErD,EAAM,MAAA,MAAA,GAASC,+BAAgB,CAAA,cAAA,CAAe,IAAI,CAAA,CAAA;AAClD,EAAM,MAAA,SAAA,GAAYC,iCAAoB,CAAA,UAAA,CAAW,MAAM,CAAA,CAAA;AACvD,EAAM,MAAA,SAAA,GAAY,MAAMC,4BAAU,CAAA,UAAA,CAAW,QAAQ,EAAE,MAAA,EAAQ,WAAW,CAAA,CAAA;AAG1E,EAAA,MAAM,EAAE,WAAA,EAAgB,GAAA,MAAM,UAAU,YAAa,EAAA,CAAA;AACrD,EAAA,IAAI,CAAC,WAAa,EAAA;AAEhB,IAAA,OAAO,OAAQ,CAAA,MAAA,CAAO,IAAI,KAAA,CAAM,EAAE,CAAC,CAAA,CAAA;AAAA,GACrC;AAEA,EAAM,MAAA,CAAC,WAAW,IAAM,EAAA,IAAI,IAAI,IAAK,CAAA,MAAA,CAAO,MAAM,GAAG,CAAA,CAAA;AACrD,EAAA,MAAM,MAAS,GAAA;AAAA,IACb,IAAA;AAAA,IACA,QAAU,EAAA;AAAA,MACR,SAAA;AAAA,MACA,IAAA;AAAA,KACF;AAAA,GACF,CAAA;AAEA,EAAM,MAAA,SAAA,GAAYC,YAAQ,CAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AACxC,EAAA,MAAM,SAAU,CAAA,OAAA,CAAQ,EAAE,MAAA,EAAQ,WAAW,CAAA,CAAA;AAE7C,EAAO,OAAA,IAAA,CAAA;AACT;;;;"}
@@ -6,11 +6,13 @@ var cliCommon = require('@backstage/cli-common');
6
6
  var serveHandler = require('serve-handler');
7
7
  var http = require('http');
8
8
  var httpProxy = require('http-proxy');
9
- var utility = require('./utility-8be2be15.cjs.js');
9
+ var utility = require('./utility-2edd5bff.cjs.js');
10
10
  var mkdocsServer = require('./mkdocsServer-db7109fb.cjs.js');
11
11
  var pluginTechdocsNode = require('@backstage/plugin-techdocs-node');
12
12
  var fs = require('fs-extra');
13
13
  require('winston');
14
+ require('stream');
15
+ require('process');
14
16
  require('child_process');
15
17
 
16
18
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -176,4 +178,4 @@ Opening browser.`
176
178
  }
177
179
 
178
180
  exports["default"] = serve;
179
- //# sourceMappingURL=serve-aea8398a.cjs.js.map
181
+ //# sourceMappingURL=serve-8c722cc8.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"serve-aea8398a.cjs.js","sources":["../../../src/lib/httpServer.ts","../../../src/commands/serve/serve.ts"],"sourcesContent":["/*\n * Copyright 2020 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 serveHandler from 'serve-handler';\nimport http from 'http';\nimport httpProxy from 'http-proxy';\nimport { createLogger } from './utility';\n\nexport default class HTTPServer {\n private readonly proxyEndpoint: string;\n private readonly backstageBundleDir: string;\n private readonly backstagePort: number;\n private readonly mkdocsTargetAddress: string;\n private readonly verbose: boolean;\n\n constructor(\n backstageBundleDir: string,\n backstagePort: number,\n mkdocsTargetAddress: string,\n verbose: boolean,\n ) {\n this.proxyEndpoint = '/api/techdocs/';\n this.backstageBundleDir = backstageBundleDir;\n this.backstagePort = backstagePort;\n this.mkdocsTargetAddress = mkdocsTargetAddress;\n this.verbose = verbose;\n }\n\n // Create a Proxy for mkdocs server\n private createProxy() {\n const proxy = httpProxy.createProxyServer({\n target: this.mkdocsTargetAddress,\n });\n\n return (request: http.IncomingMessage): [httpProxy, string] => {\n // If the request path is prefixed with this.proxyEndpoint, remove it.\n const proxyEndpointPath = new RegExp(`^${this.proxyEndpoint}`, 'i');\n const forwardPath = request.url?.replace(proxyEndpointPath, '') || '';\n\n return [proxy, forwardPath];\n };\n }\n\n public async serve(): Promise<http.Server> {\n return new Promise<http.Server>((resolve, reject) => {\n const proxyHandler = this.createProxy();\n const server = http.createServer(\n (request: http.IncomingMessage, response: http.ServerResponse) => {\n if (request.url?.startsWith(this.proxyEndpoint)) {\n const [proxy, forwardPath] = proxyHandler(request);\n\n proxy.on('error', (error: Error) => {\n reject(error);\n });\n\n response.setHeader('Access-Control-Allow-Origin', '*');\n response.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');\n\n request.url = forwardPath;\n proxy.web(request, response);\n return;\n }\n\n // This endpoint is used by the frontend to detect where the backend is running.\n if (request.url === '/.detect') {\n response.setHeader('Content-Type', 'text/plain');\n response.end('techdocs-cli-server');\n return;\n }\n\n serveHandler(request, response, {\n public: this.backstageBundleDir,\n trailingSlash: true,\n rewrites: [{ source: '**', destination: 'index.html' }],\n });\n },\n );\n\n const logger = createLogger({ verbose: false });\n server.listen(this.backstagePort, () => {\n if (this.verbose) {\n logger.info(\n `[techdocs-preview-bundle] Running local version of Backstage at http://localhost:${this.backstagePort}`,\n );\n }\n resolve(server);\n });\n\n server.on('error', (error: Error) => {\n reject(error);\n });\n });\n }\n}\n","/*\n * Copyright 2020 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 { OptionValues } from 'commander';\nimport path from 'path';\nimport openBrowser from 'react-dev-utils/openBrowser';\nimport { findPaths } from '@backstage/cli-common';\nimport HTTPServer from '../../lib/httpServer';\nimport { runMkdocsServer } from '../../lib/mkdocsServer';\nimport { LogFunc, waitForSignal } from '../../lib/run';\nimport { createLogger } from '../../lib/utility';\nimport { getMkdocsYml } from '@backstage/plugin-techdocs-node';\nimport fs from 'fs-extra';\n\nfunction findPreviewBundlePath(): string {\n try {\n return path.join(\n path.dirname(require.resolve('techdocs-cli-embedded-app/package.json')),\n 'dist',\n );\n } catch {\n // If the techdocs-cli-embedded-app package is not available it means we're\n // running a published package. For published packages the preview bundle is\n // copied to dist/embedded-app be the prepack script.\n //\n // This can be tested by running `yarn pack` and extracting the resulting tarball into a directory.\n // Within the extracted directory, run `npm install --only=prod`.\n // Once that's done you can test the CLI in any directory using `node <tmp-dir>/package <command>`.\n // eslint-disable-next-line no-restricted-syntax\n return findPaths(__dirname).resolveOwn('dist/embedded-app');\n }\n}\n\nfunction getPreviewAppPath(opts: OptionValues): string {\n return opts.previewAppBundlePath ?? findPreviewBundlePath();\n}\n\nexport default async function serve(opts: OptionValues) {\n const logger = createLogger({ verbose: opts.verbose });\n\n // Determine if we want to run in local dev mode or not\n // This will run the backstage http server on a different port and only used\n // for proxying mkdocs to the backstage app running locally (e.g. with webpack-dev-server)\n const isDevMode = Object.keys(process.env).includes('TECHDOCS_CLI_DEV_MODE')\n ? true\n : false;\n\n const backstageBackendPort = 7007;\n\n const mkdocsDockerAddr = `http://0.0.0.0:${opts.mkdocsPort}`;\n const mkdocsLocalAddr = `http://127.0.0.1:${opts.mkdocsPort}`;\n const mkdocsExpectedDevAddr = opts.docker\n ? mkdocsDockerAddr\n : mkdocsLocalAddr;\n\n const { path: mkdocsYmlPath, configIsTemporary } = await getMkdocsYml(\n './',\n opts.siteName,\n );\n\n let mkdocsServerHasStarted = false;\n const mkdocsLogFunc: LogFunc = data => {\n // Sometimes the lines contain an unnecessary extra new line\n const logLines = data.toString().split('\\n');\n const logPrefix = opts.docker ? '[docker/mkdocs]' : '[mkdocs]';\n logLines.forEach(line => {\n if (line === '') {\n return;\n }\n\n logger.verbose(`${logPrefix} ${line}`);\n\n // When the server has started, open a new browser tab for the user.\n if (\n !mkdocsServerHasStarted &&\n line.includes(`Serving on ${mkdocsExpectedDevAddr}`)\n ) {\n mkdocsServerHasStarted = true;\n }\n });\n };\n // mkdocs writes all of its logs to stderr by default, and not stdout.\n // https://github.com/mkdocs/mkdocs/issues/879#issuecomment-203536006\n // Had me questioning this whole implementation for half an hour.\n logger.info('Starting mkdocs server.');\n const mkdocsChildProcess = await runMkdocsServer({\n port: opts.mkdocsPort,\n dockerImage: opts.dockerImage,\n dockerEntrypoint: opts.dockerEntrypoint,\n dockerOptions: opts.dockerOption,\n useDocker: opts.docker,\n stdoutLogFunc: mkdocsLogFunc,\n stderrLogFunc: mkdocsLogFunc,\n });\n\n // Wait until mkdocs server has started so that Backstage starts with docs loaded\n // Takes 1-5 seconds\n for (let attempt = 0; attempt < 30; attempt++) {\n await new Promise(r => setTimeout(r, 3000));\n if (mkdocsServerHasStarted) {\n break;\n }\n logger.info('Waiting for mkdocs server to start...');\n }\n\n if (!mkdocsServerHasStarted) {\n logger.error(\n 'mkdocs server did not start. Exiting. Try re-running command with -v option for more details.',\n );\n }\n\n const port = isDevMode ? backstageBackendPort : opts.previewAppPort;\n const previewAppPath = getPreviewAppPath(opts);\n const httpServer = new HTTPServer(\n previewAppPath,\n port,\n mkdocsExpectedDevAddr,\n opts.verbose,\n );\n\n httpServer\n .serve()\n .catch(err => {\n logger.error('Failed to start HTTP server', err);\n mkdocsChildProcess.kill();\n process.exit(1);\n })\n .then(() => {\n // The last three things default/component/local/ don't matter. They can be anything.\n openBrowser(`http://localhost:${port}/docs/default/component/local/`);\n logger.info(\n `Serving docs in Backstage at http://localhost:${port}/docs/default/component/local/\\nOpening browser.`,\n );\n });\n\n await waitForSignal([mkdocsChildProcess]);\n\n if (configIsTemporary) {\n process.on('exit', async () => {\n fs.rmSync(mkdocsYmlPath, {});\n });\n }\n}\n"],"names":["httpProxy","http","serveHandler","createLogger","path","findPaths","getMkdocsYml","runMkdocsServer","openBrowser","waitForSignal","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAqB,UAAW,CAAA;AAAA,EAO9B,WACE,CAAA,kBAAA,EACA,aACA,EAAA,mBAAA,EACA,OACA,EAAA;AACA,IAAA,IAAA,CAAK,aAAgB,GAAA,gBAAA,CAAA;AACrB,IAAA,IAAA,CAAK,kBAAqB,GAAA,kBAAA,CAAA;AAC1B,IAAA,IAAA,CAAK,aAAgB,GAAA,aAAA,CAAA;AACrB,IAAA,IAAA,CAAK,mBAAsB,GAAA,mBAAA,CAAA;AAC3B,IAAA,IAAA,CAAK,OAAU,GAAA,OAAA,CAAA;AAAA,GACjB;AAAA;AAAA,EAGQ,WAAc,GAAA;AACpB,IAAM,MAAA,KAAA,GAAQA,8BAAU,iBAAkB,CAAA;AAAA,MACxC,QAAQ,IAAK,CAAA,mBAAA;AAAA,KACd,CAAA,CAAA;AAED,IAAA,OAAO,CAAC,OAAuD,KAAA;AA/CnE,MAAA,IAAA,EAAA,CAAA;AAiDM,MAAA,MAAM,oBAAoB,IAAI,MAAA,CAAO,CAAI,CAAA,EAAA,IAAA,CAAK,iBAAiB,GAAG,CAAA,CAAA;AAClE,MAAA,MAAM,gBAAc,EAAQ,GAAA,OAAA,CAAA,GAAA,KAAR,IAAa,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAA,CAAQ,mBAAmB,EAAO,CAAA,KAAA,EAAA,CAAA;AAEnE,MAAO,OAAA,CAAC,OAAO,WAAW,CAAA,CAAA;AAAA,KAC5B,CAAA;AAAA,GACF;AAAA,EAEA,MAAa,KAA8B,GAAA;AACzC,IAAA,OAAO,IAAI,OAAA,CAAqB,CAAC,OAAA,EAAS,MAAW,KAAA;AACnD,MAAM,MAAA,YAAA,GAAe,KAAK,WAAY,EAAA,CAAA;AACtC,MAAA,MAAM,SAASC,wBAAK,C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AAA,CAAA,CAAA;AACpE,IAAO,MAAA,CAAA,IAAA;AAAA,MACL,CAAiD,8CAAA,EAAA,IAAA,CAAA;AAAA,gBAAA,CAAA;AAAA,KACnD,CAAA;AAAA,GACD,CAAA,CAAA;AAEH,EAAM,MAAAC,0BAAA,CAAc,CAAC,kBAAkB,CAAC,CAAA,CAAA;AAExC,EAAA,IAAI,iBAAmB,EAAA;AACrB,IAAQ,OAAA,CAAA,EAAA,CAAG,QAAQ,YAAY;AAC7B,MAAGC,sBAAA,CAAA,MAAA,CAAO,aAAe,EAAA,EAAE,CAAA,CAAA;AAAA,KAC5B,CAAA,CAAA;AAAA,GACH;AACF;;;;"}
1
+ {"version":3,"file":"serve-8c722cc8.cjs.js","sources":["../../../src/lib/httpServer.ts","../../../src/commands/serve/serve.ts"],"sourcesContent":["/*\n * Copyright 2020 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 serveHandler from 'serve-handler';\nimport http from 'http';\nimport httpProxy from 'http-proxy';\nimport { createLogger } from './utility';\n\nexport default class HTTPServer {\n private readonly proxyEndpoint: string;\n private readonly backstageBundleDir: string;\n private readonly backstagePort: number;\n private readonly mkdocsTargetAddress: string;\n private readonly verbose: boolean;\n\n constructor(\n backstageBundleDir: string,\n backstagePort: number,\n mkdocsTargetAddress: string,\n verbose: boolean,\n ) {\n this.proxyEndpoint = '/api/techdocs/';\n this.backstageBundleDir = backstageBundleDir;\n this.backstagePort = backstagePort;\n this.mkdocsTargetAddress = mkdocsTargetAddress;\n this.verbose = verbose;\n }\n\n // Create a Proxy for mkdocs server\n private createProxy() {\n const proxy = httpProxy.createProxyServer({\n target: this.mkdocsTargetAddress,\n });\n\n return (request: http.IncomingMessage): [httpProxy, string] => {\n // If the request path is prefixed with this.proxyEndpoint, remove it.\n const proxyEndpointPath = new RegExp(`^${this.proxyEndpoint}`, 'i');\n const forwardPath = request.url?.replace(proxyEndpointPath, '') || '';\n\n return [proxy, forwardPath];\n };\n }\n\n public async serve(): Promise<http.Server> {\n return new Promise<http.Server>((resolve, reject) => {\n const proxyHandler = this.createProxy();\n const server = http.createServer(\n (request: http.IncomingMessage, response: http.ServerResponse) => {\n if (request.url?.startsWith(this.proxyEndpoint)) {\n const [proxy, forwardPath] = proxyHandler(request);\n\n proxy.on('error', (error: Error) => {\n reject(error);\n });\n\n response.setHeader('Access-Control-Allow-Origin', '*');\n response.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');\n\n request.url = forwardPath;\n proxy.web(request, response);\n return;\n }\n\n // This endpoint is used by the frontend to detect where the backend is running.\n if (request.url === '/.detect') {\n response.setHeader('Content-Type', 'text/plain');\n response.end('techdocs-cli-server');\n return;\n }\n\n serveHandler(request, response, {\n public: this.backstageBundleDir,\n trailingSlash: true,\n rewrites: [{ source: '**', destination: 'index.html' }],\n });\n },\n );\n\n const logger = createLogger({ verbose: false });\n server.listen(this.backstagePort, () => {\n if (this.verbose) {\n logger.info(\n `[techdocs-preview-bundle] Running local version of Backstage at http://localhost:${this.backstagePort}`,\n );\n }\n resolve(server);\n });\n\n server.on('error', (error: Error) => {\n reject(error);\n });\n });\n }\n}\n","/*\n * Copyright 2020 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 { OptionValues } from 'commander';\nimport path from 'path';\nimport openBrowser from 'react-dev-utils/openBrowser';\nimport { findPaths } from '@backstage/cli-common';\nimport HTTPServer from '../../lib/httpServer';\nimport { runMkdocsServer } from '../../lib/mkdocsServer';\nimport { LogFunc, waitForSignal } from '../../lib/run';\nimport { createLogger } from '../../lib/utility';\nimport { getMkdocsYml } from '@backstage/plugin-techdocs-node';\nimport fs from 'fs-extra';\n\nfunction findPreviewBundlePath(): string {\n try {\n return path.join(\n path.dirname(require.resolve('techdocs-cli-embedded-app/package.json')),\n 'dist',\n );\n } catch {\n // If the techdocs-cli-embedded-app package is not available it means we're\n // running a published package. For published packages the preview bundle is\n // copied to dist/embedded-app be the prepack script.\n //\n // This can be tested by running `yarn pack` and extracting the resulting tarball into a directory.\n // Within the extracted directory, run `npm install --only=prod`.\n // Once that's done you can test the CLI in any directory using `node <tmp-dir>/package <command>`.\n // eslint-disable-next-line no-restricted-syntax\n return findPaths(__dirname).resolveOwn('dist/embedded-app');\n }\n}\n\nfunction getPreviewAppPath(opts: OptionValues): string {\n return opts.previewAppBundlePath ?? findPreviewBundlePath();\n}\n\nexport default async function serve(opts: OptionValues) {\n const logger = createLogger({ verbose: opts.verbose });\n\n // Determine if we want to run in local dev mode or not\n // This will run the backstage http server on a different port and only used\n // for proxying mkdocs to the backstage app running locally (e.g. with webpack-dev-server)\n const isDevMode = Object.keys(process.env).includes('TECHDOCS_CLI_DEV_MODE')\n ? true\n : false;\n\n const backstageBackendPort = 7007;\n\n const mkdocsDockerAddr = `http://0.0.0.0:${opts.mkdocsPort}`;\n const mkdocsLocalAddr = `http://127.0.0.1:${opts.mkdocsPort}`;\n const mkdocsExpectedDevAddr = opts.docker\n ? mkdocsDockerAddr\n : mkdocsLocalAddr;\n\n const { path: mkdocsYmlPath, configIsTemporary } = await getMkdocsYml(\n './',\n opts.siteName,\n );\n\n let mkdocsServerHasStarted = false;\n const mkdocsLogFunc: LogFunc = data => {\n // Sometimes the lines contain an unnecessary extra new line\n const logLines = data.toString().split('\\n');\n const logPrefix = opts.docker ? '[docker/mkdocs]' : '[mkdocs]';\n logLines.forEach(line => {\n if (line === '') {\n return;\n }\n\n logger.verbose(`${logPrefix} ${line}`);\n\n // When the server has started, open a new browser tab for the user.\n if (\n !mkdocsServerHasStarted &&\n line.includes(`Serving on ${mkdocsExpectedDevAddr}`)\n ) {\n mkdocsServerHasStarted = true;\n }\n });\n };\n // mkdocs writes all of its logs to stderr by default, and not stdout.\n // https://github.com/mkdocs/mkdocs/issues/879#issuecomment-203536006\n // Had me questioning this whole implementation for half an hour.\n logger.info('Starting mkdocs server.');\n const mkdocsChildProcess = await runMkdocsServer({\n port: opts.mkdocsPort,\n dockerImage: opts.dockerImage,\n dockerEntrypoint: opts.dockerEntrypoint,\n dockerOptions: opts.dockerOption,\n useDocker: opts.docker,\n stdoutLogFunc: mkdocsLogFunc,\n stderrLogFunc: mkdocsLogFunc,\n });\n\n // Wait until mkdocs server has started so that Backstage starts with docs loaded\n // Takes 1-5 seconds\n for (let attempt = 0; attempt < 30; attempt++) {\n await new Promise(r => setTimeout(r, 3000));\n if (mkdocsServerHasStarted) {\n break;\n }\n logger.info('Waiting for mkdocs server to start...');\n }\n\n if (!mkdocsServerHasStarted) {\n logger.error(\n 'mkdocs server did not start. Exiting. Try re-running command with -v option for more details.',\n );\n }\n\n const port = isDevMode ? backstageBackendPort : opts.previewAppPort;\n const previewAppPath = getPreviewAppPath(opts);\n const httpServer = new HTTPServer(\n previewAppPath,\n port,\n mkdocsExpectedDevAddr,\n opts.verbose,\n );\n\n httpServer\n .serve()\n .catch(err => {\n logger.error('Failed to start HTTP server', err);\n mkdocsChildProcess.kill();\n process.exit(1);\n })\n .then(() => {\n // The last three things default/component/local/ don't matter. They can be anything.\n openBrowser(`http://localhost:${port}/docs/default/component/local/`);\n logger.info(\n `Serving docs in Backstage at http://localhost:${port}/docs/default/component/local/\\nOpening browser.`,\n );\n });\n\n await waitForSignal([mkdocsChildProcess]);\n\n if (configIsTemporary) {\n process.on('exit', async () => {\n fs.rmSync(mkdocsYmlPath, {});\n });\n }\n}\n"],"names":["httpProxy","http","serveHandler","createLogger","path","findPaths","getMkdocsYml","runMkdocsServer","openBrowser","waitForSignal","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAqB,UAAW,CAAA;AAAA,EAO9B,WACE,CAAA,kBAAA,EACA,aACA,EAAA,mBAAA,EACA,OACA,EAAA;AACA,IAAA,IAAA,CAAK,aAAgB,GAAA,gBAAA,CAAA;AACrB,IAAA,IAAA,CAAK,kBAAqB,GAAA,kBAAA,CAAA;AAC1B,IAAA,IAAA,CAAK,aAAgB,GAAA,aAAA,CAAA;AACrB,IAAA,IAAA,CAAK,mBAAsB,GAAA,mBAAA,CAAA;AAC3B,IAAA,IAAA,CAAK,OAAU,GAAA,OAAA,CAAA;AAAA,GACjB;AAAA;AAAA,EAGQ,WAAc,GAAA;AACpB,IAAM,MAAA,KAAA,GAAQA,8BAAU,iBAAkB,CAAA;AAAA,MACxC,QAAQ,IAAK,CAAA,mBAAA;AAAA,KACd,CAAA,CAAA;AAED,IAAA,OAAO,CAAC,OAAuD,KAAA;AA/CnE,MAAA,IAAA,EAAA,CAAA;AAiDM,MAAA,MAAM,oBAAoB,IAAI,MAAA,CAAO,CAAI,CAAA,EAAA,IAAA,CAAK,iBAAiB,GAAG,CAAA,CAAA;AAClE,MAAA,MAAM,gBAAc,EAAQ,GAAA,OAAA,CAAA,GAAA,KAAR,IAAa,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAA,CAAQ,mBAAmB,EAAO,CAAA,KAAA,EAAA,CAAA;AAEnE,MAAO,OAAA,CAAC,OAAO,WAAW,CAAA,CAAA;AAAA,KAC5B,CAAA;AAAA,GACF;AAAA,EAEA,MAAa,KAA8B,GAAA;AACzC,IAAA,OAAO,IAAI,OAAA,CAAqB,CAAC,OAAA,EAAS,MAAW,KAAA;AACnD,MAAM,MAAA,YAAA,GAAe,KAAK,WAAY,EAAA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AA,CAAY,oBAAoB,IAAoC,CAAA,8BAAA,CAAA,CAAA,CAAA;AACpE,IAAO,MAAA,CAAA,IAAA;AAAA,MACL,CAAiD,8CAAA,EAAA,IAAA,CAAA;AAAA,gBAAA,CAAA;AAAA,KACnD,CAAA;AAAA,GACD,CAAA,CAAA;AAEH,EAAM,MAAAC,0BAAA,CAAc,CAAC,kBAAkB,CAAC,CAAA,CAAA;AAExC,EAAA,IAAI,iBAAmB,EAAA;AACrB,IAAQ,OAAA,CAAA,EAAA,CAAG,QAAQ,YAAY;AAC7B,MAAGC,sBAAA,CAAA,MAAA,CAAO,aAAe,EAAA,EAAE,CAAA,CAAA;AAAA,KAC5B,CAAA,CAAA;AAAA,GACH;AACF;;;;"}
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var winston = require('winston');
4
+ var stream = require('stream');
5
+ var process$1 = require('process');
4
6
 
5
7
  function _interopNamespace(e) {
6
8
  if (e && e.__esModule) return e;
@@ -42,7 +44,20 @@ const createLogger = ({
42
44
  });
43
45
  return logger;
44
46
  };
47
+ const getLogStream = (logger) => {
48
+ if (process.env.LOG_LEVEL === "debug") {
49
+ return process$1.stdout;
50
+ }
51
+ return new stream.Writable({
52
+ defaultEncoding: "utf8",
53
+ write(chunk, _encoding, next) {
54
+ logger.verbose(chunk.toString().trim());
55
+ next();
56
+ }
57
+ });
58
+ };
45
59
 
46
60
  exports.convertTechDocsRefToLocationAnnotation = convertTechDocsRefToLocationAnnotation;
47
61
  exports.createLogger = createLogger;
48
- //# sourceMappingURL=utility-8be2be15.cjs.js.map
62
+ exports.getLogStream = getLogStream;
63
+ //# sourceMappingURL=utility-2edd5bff.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utility-2edd5bff.cjs.js","sources":["../../../src/lib/utility.ts"],"sourcesContent":["/*\n * Copyright 2020 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 {\n RemoteProtocol,\n ParsedLocationAnnotation,\n} from '@backstage/plugin-techdocs-node';\nimport * as winston from 'winston';\nimport { Writable } from 'stream';\nimport { stdout } from 'process';\n\nexport const convertTechDocsRefToLocationAnnotation = (\n techdocsRef: string,\n): ParsedLocationAnnotation => {\n // Split on the first colon for the protocol and the rest after the first split\n // is the location.\n const [type, target] = techdocsRef.split(/:(.+)/) as [\n RemoteProtocol?,\n string?,\n ];\n\n if (!type || !target) {\n throw new Error(\n `Can not parse --techdocs-ref ${techdocsRef}. Should be of type HOST:URL.`,\n );\n }\n\n return { type, target };\n};\n\nexport const createLogger = ({\n verbose = false,\n}: {\n verbose: boolean;\n}): winston.Logger => {\n const logger = winston.createLogger({\n level: verbose ? 'verbose' : 'info',\n transports: [\n new winston.transports.Console({ format: winston.format.simple() }),\n ],\n });\n\n return logger;\n};\n\nexport const getLogStream = (logger: winston.Logger): Writable => {\n if (process.env.LOG_LEVEL === 'debug') {\n return stdout;\n }\n\n return new Writable({\n defaultEncoding: 'utf8',\n write(chunk, _encoding, next) {\n logger.verbose(chunk.toString().trim());\n next();\n },\n });\n};\n"],"names":["winston","stdout","Writable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuBa,MAAA,sCAAA,GAAyC,CACpD,WAC6B,KAAA;AAG7B,EAAA,MAAM,CAAC,IAAM,EAAA,MAAM,CAAI,GAAA,WAAA,CAAY,MAAM,OAAO,CAAA,CAAA;AAKhD,EAAI,IAAA,CAAC,IAAQ,IAAA,CAAC,MAAQ,EAAA;AACpB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAgC,6BAAA,EAAA,WAAA,CAAA,6BAAA,CAAA;AAAA,KAClC,CAAA;AAAA,GACF;AAEA,EAAO,OAAA,EAAE,MAAM,MAAO,EAAA,CAAA;AACxB,EAAA;AAEO,MAAM,eAAe,CAAC;AAAA,EAC3B,OAAU,GAAA,KAAA;AACZ,CAEsB,KAAA;AACpB,EAAM,MAAA,MAAA,GAASA,mBAAQ,YAAa,CAAA;AAAA,IAClC,KAAA,EAAO,UAAU,SAAY,GAAA,MAAA;AAAA,IAC7B,UAAY,EAAA;AAAA,MACV,IAAIA,kBAAQ,CAAA,UAAA,CAAW,OAAQ,CAAA,EAAE,QAAQA,kBAAQ,CAAA,MAAA,CAAO,MAAO,EAAA,EAAG,CAAA;AAAA,KACpE;AAAA,GACD,CAAA,CAAA;AAED,EAAO,OAAA,MAAA,CAAA;AACT,EAAA;AAEa,MAAA,YAAA,GAAe,CAAC,MAAqC,KAAA;AAChE,EAAI,IAAA,OAAA,CAAQ,GAAI,CAAA,SAAA,KAAc,OAAS,EAAA;AACrC,IAAO,OAAAC,gBAAA,CAAA;AAAA,GACT;AAEA,EAAA,OAAO,IAAIC,eAAS,CAAA;AAAA,IAClB,eAAiB,EAAA,MAAA;AAAA,IACjB,KAAA,CAAM,KAAO,EAAA,SAAA,EAAW,IAAM,EAAA;AAC5B,MAAA,MAAA,CAAO,OAAQ,CAAA,KAAA,CAAM,QAAS,EAAA,CAAE,MAAM,CAAA,CAAA;AACtC,MAAK,IAAA,EAAA,CAAA;AAAA,KACP;AAAA,GACD,CAAA,CAAA;AACH;;;;;;"}
@@ -833,6 +833,10 @@
833
833
  ],
834
834
  "type": "string"
835
835
  },
836
+ "role": {
837
+ "description": "Configures the ownership of newly created schemas in pg databases.",
838
+ "type": "string"
839
+ },
836
840
  "knexConfig": {
837
841
  "description": "Arbitrary config object to pass to knex when initializing\n(https://knexjs.org/#Installation-client). Most notable is the debug\nand asyncStackTraces booleans",
838
842
  "type": "object",
@@ -877,6 +881,10 @@
877
881
  "type": "object",
878
882
  "properties": {},
879
883
  "additionalProperties": true
884
+ },
885
+ "role": {
886
+ "description": "Configures the ownership of newly created schemas in pg databases.",
887
+ "type": "string"
880
888
  }
881
889
  }
882
890
  }
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Backstage is an open platform for building developer portals"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json" crossorigin="use-credentials"/><link rel="icon" href="/favicon.ico"/><link rel="shortcut icon" href="/favicon.ico"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"/><title>Techdocs Preview App</title><script defer="defer" src="/static/runtime.ca2552f1.js"></script><script defer="defer" src="/static/module-material-ui.617f168b.js"></script><script defer="defer" src="/static/module-lodash.b0e3bf8c.js"></script><script defer="defer" src="/static/module-date-fns.eeb6d2d2.js"></script><script defer="defer" src="/static/module-yaml.2570b3eb.js"></script><script defer="defer" src="/static/module-ajv.be583887.js"></script><script defer="defer" src="/static/module-material-table.2aa637a9.js"></script><script defer="defer" src="/static/module-luxon.f096b58d.js"></script><script defer="defer" src="/static/module-octokit.10809b9e.js"></script><script defer="defer" src="/static/module-react-dom.d698fbed.js"></script><script defer="defer" src="/static/module-zod.cdb212b6.js"></script><script defer="defer" src="/static/module-react-beautiful-dnd.c3c3faee.js"></script><script defer="defer" src="/static/module-remix-run.4d35bb97.js"></script><script defer="defer" src="/static/vendor.ca2552f1.js"></script><script defer="defer" src="/static/main.ca2552f1.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Backstage is an open platform for building developer portals"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json" crossorigin="use-credentials"/><link rel="icon" href="/favicon.ico"/><link rel="shortcut icon" href="/favicon.ico"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"/><title>Techdocs Preview App</title><script defer="defer" src="/static/runtime.e99a7512.js"></script><script defer="defer" src="/static/module-material-ui.617f168b.js"></script><script defer="defer" src="/static/module-lodash.b0e3bf8c.js"></script><script defer="defer" src="/static/module-date-fns.eeb6d2d2.js"></script><script defer="defer" src="/static/module-yaml.2570b3eb.js"></script><script defer="defer" src="/static/module-ajv.be583887.js"></script><script defer="defer" src="/static/module-material-table.2aa637a9.js"></script><script defer="defer" src="/static/module-luxon.f096b58d.js"></script><script defer="defer" src="/static/module-octokit.10809b9e.js"></script><script defer="defer" src="/static/module-react-dom.d698fbed.js"></script><script defer="defer" src="/static/module-zod.cdb212b6.js"></script><script defer="defer" src="/static/module-react-beautiful-dnd.c3c3faee.js"></script><script defer="defer" src="/static/module-remix-run.4d35bb97.js"></script><script defer="defer" src="/static/vendor.e99a7512.js"></script><script defer="defer" src="/static/main.e99a7512.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
@@ -0,0 +1,3 @@
1
+ "use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[1032,732],{81032:function(f,i,n){n.r(i),n.d(i,{DependsOnResourcesCard:function(){return s}});var e=n(52322),c=n(25271),t=n(2784),r=n(732);function s(u){const{variant:a="gridItem",title:l="Depends on resources",columns:m=r.resourceEntityColumns}=u;return(0,e.jsx)(r.RelatedEntitiesCard,{variant:a,title:l,entityKind:"Resource",relationType:c.nP,columns:m,emptyMessage:"No resource is a dependency of this component",emptyHelpLink:r.componentEntityHelpLink,asRenderableEntities:r.asResourceEntities})}},732:function(f,i,n){n.r(i),n.d(i,{RelatedEntitiesCard:function(){return u},asComponentEntities:function(){return m},asResourceEntities:function(){return h},asSystemEntities:function(){return g},componentEntityColumns:function(){return a},componentEntityHelpLink:function(){return l},resourceEntityColumns:function(){return C},resourceEntityHelpLink:function(){return E},systemEntityColumns:function(){return v},systemEntityHelpLink:function(){return R}});var e=n(52322),c=n(90436),t=n(40303),r=n(2784),s=n(23196);function u(o){const{variant:d="gridItem",title:y,columns:j,entityKind:x,relationType:L,emptyMessage:k,emptyHelpLink:H,asRenderableEntities:D}=o,{entity:K}=(0,t.X2)(),{entities:S,loading:M,error:p}=(0,t.eK)(K,{type:L,kind:x});return M?(0,e.jsx)(s.rJ,{variant:d,title:y,children:(0,e.jsx)(s.Ex,{})}):p?(0,e.jsx)(s.rJ,{variant:d,title:y,children:(0,e.jsx)(s.Gk,{error:p})}):(0,e.jsx)(t.u3,{title:y,variant:d,emptyContent:(0,e.jsxs)("div",{style:{textAlign:"center"},children:[(0,e.jsx)(c.Z,{variant:"body1",children:k}),(0,e.jsx)(c.Z,{variant:"body2",children:(0,e.jsx)(s.rU,{to:H,children:"Learn how to change this."})})]}),columns:j,entities:D(S||[])})}const a=[t.u3.columns.createEntityRefColumn({defaultKind:"component"}),t.u3.columns.createOwnerColumn(),t.u3.columns.createSpecTypeColumn(),t.u3.columns.createSpecLifecycleColumn(),t.u3.columns.createMetadataDescriptionColumn()],l="https://backstage.io/docs/features/software-catalog/descriptor-format#kind-component",m=o=>o,C=[t.u3.columns.createEntityRefColumn({defaultKind:"resource"}),t.u3.columns.createOwnerColumn(),t.u3.columns.createSpecTypeColumn(),t.u3.columns.createSpecLifecycleColumn(),t.u3.columns.createMetadataDescriptionColumn()],E="https://backstage.io/docs/features/software-catalog/descriptor-format#kind-resource",h=o=>o,v=[t.u3.columns.createEntityRefColumn({defaultKind:"system"}),t.u3.columns.createOwnerColumn(),t.u3.columns.createMetadataDescriptionColumn()],R="https://backstage.io/docs/features/software-catalog/descriptor-format#kind-system",g=o=>o}}]);})();
2
+
3
+ //# sourceMappingURL=1032.90746959.chunk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static/1032.90746959.chunk.js","mappings":"gQAiCO,SAASA,EAAuBC,EAAoC,CACzE,KAAM,CACJC,QAAAA,EAAU,WACVC,MAAAA,EAAQ,uBACRC,QAAAA,EAAUC,EAAAA,qBAAqB,EAC7BJ,EACJ,SACE,OAACK,EAAAA,oBAAmBA,CAClBJ,QAASA,EACTC,MAAOA,EACPI,WAAW,WACXC,aAAcC,EAAAA,GACdL,QAASA,EACTM,aAAa,gDACbC,cAAeC,EAAAA,wBACfC,qBAAsBC,EAAAA,kB,EAG5B,C,mgBCMO,SAASR,EACdL,EACA,CACA,KAAM,CACJC,QAAAA,EAAU,WACVC,MAAAA,EACAC,QAAAA,EACAG,WAAAA,EACAC,aAAAA,EACAE,aAAAA,EACAC,cAAAA,EACAE,qBAAAA,CAAoB,EAClBZ,EAEE,CAAEc,OAAAA,CAAO,KAAIC,EAAAA,IAAU,EACvB,CAAEC,SAAAA,EAAUC,QAAAA,EAASC,MAAAA,CAAM,KAAIC,EAAAA,IAAmBL,EAAQ,CAC9DM,KAAMb,EACNc,KAAMf,CACR,CAAC,EAED,OAAIW,KAEA,OAACK,EAAAA,GAAQA,CAACrB,QAASA,EAASC,MAAOA,E,YACjC,OAACqB,EAAAA,GAAQA,CAAAA,CAAAA,C,GAKXL,KAEA,OAACI,EAAAA,GAAQA,CAACrB,QAASA,EAASC,MAAOA,E,YACjC,OAACsB,EAAAA,GAAkBA,CAACN,MAAOA,C,QAM/B,OAACO,EAAAA,GAAWA,CACVvB,MAAOA,EACPD,QAASA,EACTyB,gBACE,QAACC,MAAAA,CAAIC,MAAO,CAAEC,UAAW,QAAS,E,aAChC,OAACC,EAAAA,EAAUA,CAAC7B,QAAQ,Q,SAASQ,C,MAC7B,OAACqB,EAAAA,EAAUA,CAAC7B,QAAQ,Q,YAClB,OAAC8B,EAAAA,GAAIA,CAACC,GAAItB,E,SAAe,2B,QAI/BP,QAASA,EACTa,SAAUJ,EAAqBI,GAAY,CAAC,CAAC,C,EAGnD,CCrFO,MAAMiB,EAAyD,CACpER,EAAAA,GAAAA,QAAAA,sBAA0C,CAAES,YAAa,WAAY,CAAC,EACtET,EAAAA,GAAAA,QAAAA,kBAAsC,EACtCA,EAAAA,GAAAA,QAAAA,qBAAyC,EACzCA,EAAAA,GAAAA,QAAAA,0BAA8C,EAC9CA,EAAAA,GAAAA,QAAAA,gCAAoD,C,EAEzCd,EACX,uFACWwB,EAAuBnB,GAClCA,EAEWZ,EAAuD,CAClEqB,EAAAA,GAAAA,QAAAA,sBAA0C,CAAES,YAAa,UAAW,CAAC,EACrET,EAAAA,GAAAA,QAAAA,kBAAsC,EACtCA,EAAAA,GAAAA,QAAAA,qBAAyC,EACzCA,EAAAA,GAAAA,QAAAA,0BAA8C,EAC9CA,EAAAA,GAAAA,QAAAA,gCAAoD,C,EAEzCW,EACX,sFACWvB,EAAsBG,GACjCA,EAEWqB,EAAmD,CAC9DZ,EAAAA,GAAAA,QAAAA,sBAA0C,CAAES,YAAa,QAAS,CAAC,EACnET,EAAAA,GAAAA,QAAAA,kBAAsC,EACtCA,EAAAA,GAAAA,QAAAA,gCAAoD,C,EAEzCa,EACX,oFACWC,EAAoBvB,GAC/BA,C","sources":["webpack://techdocs-cli-embedded-app/../../plugins/catalog/src/components/DependsOnResourcesCard/DependsOnResourcesCard.tsx","webpack://techdocs-cli-embedded-app/../../plugins/catalog/src/components/RelatedEntitiesCard/RelatedEntitiesCard.tsx","webpack://techdocs-cli-embedded-app/../../plugins/catalog/src/components/RelatedEntitiesCard/presets.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { RELATION_DEPENDS_ON, ResourceEntity } from '@backstage/catalog-model';\nimport { InfoCardVariants, TableColumn } from '@backstage/core-components';\nimport React from 'react';\nimport {\n asResourceEntities,\n componentEntityHelpLink,\n RelatedEntitiesCard,\n resourceEntityColumns,\n} from '../RelatedEntitiesCard';\n\n/** @public */\nexport interface DependsOnResourcesCardProps {\n variant?: InfoCardVariants;\n title?: string;\n columns?: TableColumn<ResourceEntity>[];\n}\n\nexport function DependsOnResourcesCard(props: DependsOnResourcesCardProps) {\n const {\n variant = 'gridItem',\n title = 'Depends on resources',\n columns = resourceEntityColumns,\n } = props;\n return (\n <RelatedEntitiesCard\n variant={variant}\n title={title}\n entityKind=\"Resource\"\n relationType={RELATION_DEPENDS_ON}\n columns={columns}\n emptyMessage=\"No resource is a dependency of this component\"\n emptyHelpLink={componentEntityHelpLink}\n asRenderableEntities={asResourceEntities}\n />\n );\n}\n","/*\n * Copyright 2020 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 { Entity } from '@backstage/catalog-model';\nimport { Typography } from '@material-ui/core';\nimport {\n EntityTable,\n useEntity,\n useRelatedEntities,\n} from '@backstage/plugin-catalog-react';\nimport React from 'react';\nimport {\n InfoCard,\n InfoCardVariants,\n Link,\n Progress,\n ResponseErrorPanel,\n TableColumn,\n} from '@backstage/core-components';\n\n/** @public */\nexport type RelatedEntitiesCardProps<T extends Entity> = {\n variant?: InfoCardVariants;\n title: string;\n columns: TableColumn<T>[];\n entityKind?: string;\n relationType: string;\n emptyMessage: string;\n emptyHelpLink: string;\n asRenderableEntities: (entities: Entity[]) => T[];\n};\n\n/**\n * A low level card component that can be used as a building block for more\n * specific cards.\n *\n * @remarks\n *\n * You probably want to make a dedicated component for your needs, which renders\n * this card as its implementation with some of the props set to the appropriate\n * values.\n *\n * @public\n */\nexport function RelatedEntitiesCard<T extends Entity>(\n props: RelatedEntitiesCardProps<T>,\n) {\n const {\n variant = 'gridItem',\n title,\n columns,\n entityKind,\n relationType,\n emptyMessage,\n emptyHelpLink,\n asRenderableEntities,\n } = props;\n\n const { entity } = useEntity();\n const { entities, loading, error } = useRelatedEntities(entity, {\n type: relationType,\n kind: entityKind,\n });\n\n if (loading) {\n return (\n <InfoCard variant={variant} title={title}>\n <Progress />\n </InfoCard>\n );\n }\n\n if (error) {\n return (\n <InfoCard variant={variant} title={title}>\n <ResponseErrorPanel error={error} />\n </InfoCard>\n );\n }\n\n return (\n <EntityTable\n title={title}\n variant={variant}\n emptyContent={\n <div style={{ textAlign: 'center' }}>\n <Typography variant=\"body1\">{emptyMessage}</Typography>\n <Typography variant=\"body2\">\n <Link to={emptyHelpLink}>Learn how to change this.</Link>\n </Typography>\n </div>\n }\n columns={columns}\n entities={asRenderableEntities(entities || [])}\n />\n );\n}\n","/*\n * Copyright 2021 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 {\n ComponentEntity,\n Entity,\n ResourceEntity,\n SystemEntity,\n} from '@backstage/catalog-model';\nimport { EntityTable } from '@backstage/plugin-catalog-react';\nimport { TableColumn } from '@backstage/core-components';\n\nexport const componentEntityColumns: TableColumn<ComponentEntity>[] = [\n EntityTable.columns.createEntityRefColumn({ defaultKind: 'component' }),\n EntityTable.columns.createOwnerColumn(),\n EntityTable.columns.createSpecTypeColumn(),\n EntityTable.columns.createSpecLifecycleColumn(),\n EntityTable.columns.createMetadataDescriptionColumn(),\n];\nexport const componentEntityHelpLink: string =\n 'https://backstage.io/docs/features/software-catalog/descriptor-format#kind-component';\nexport const asComponentEntities = (entities: Entity[]): ComponentEntity[] =>\n entities as ComponentEntity[];\n\nexport const resourceEntityColumns: TableColumn<ResourceEntity>[] = [\n EntityTable.columns.createEntityRefColumn({ defaultKind: 'resource' }),\n EntityTable.columns.createOwnerColumn(),\n EntityTable.columns.createSpecTypeColumn(),\n EntityTable.columns.createSpecLifecycleColumn(),\n EntityTable.columns.createMetadataDescriptionColumn(),\n];\nexport const resourceEntityHelpLink: string =\n 'https://backstage.io/docs/features/software-catalog/descriptor-format#kind-resource';\nexport const asResourceEntities = (entities: Entity[]): ResourceEntity[] =>\n entities as ResourceEntity[];\n\nexport const systemEntityColumns: TableColumn<SystemEntity>[] = [\n EntityTable.columns.createEntityRefColumn({ defaultKind: 'system' }),\n EntityTable.columns.createOwnerColumn(),\n EntityTable.columns.createMetadataDescriptionColumn(),\n];\nexport const systemEntityHelpLink: string =\n 'https://backstage.io/docs/features/software-catalog/descriptor-format#kind-system';\nexport const asSystemEntities = (entities: Entity[]): SystemEntity[] =>\n entities as SystemEntity[];\n"],"names":["DependsOnResourcesCard","props","variant","title","columns","resourceEntityColumns","RelatedEntitiesCard","entityKind","relationType","RELATION_DEPENDS_ON","emptyMessage","emptyHelpLink","componentEntityHelpLink","asRenderableEntities","asResourceEntities","entity","useEntity","entities","loading","error","useRelatedEntities","type","kind","InfoCard","Progress","ResponseErrorPanel","EntityTable","emptyContent","div","style","textAlign","Typography","Link","to","componentEntityColumns","defaultKind","asComponentEntities","resourceEntityHelpLink","systemEntityColumns","systemEntityHelpLink","asSystemEntities"],"sourceRoot":""}
@@ -1,3 +1,3 @@
1
1
  "use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[1105,732],{1105:function(p,i,n){n.r(i),n.d(i,{HasComponentsCard:function(){return o}});var e=n(52322),c=n(25271),t=n(2784),r=n(732);function o(a){const{variant:u="gridItem"}=a;return(0,e.jsx)(r.RelatedEntitiesCard,{variant:u,title:"Has components",entityKind:"Component",relationType:c.aS,columns:r.componentEntityColumns,emptyMessage:"No component is part of this system",emptyHelpLink:r.componentEntityHelpLink,asRenderableEntities:r.asComponentEntities})}},732:function(p,i,n){n.r(i),n.d(i,{RelatedEntitiesCard:function(){return a},asComponentEntities:function(){return f},asResourceEntities:function(){return h},asSystemEntities:function(){return j},componentEntityColumns:function(){return u},componentEntityHelpLink:function(){return y},resourceEntityColumns:function(){return C},resourceEntityHelpLink:function(){return E},systemEntityColumns:function(){return v},systemEntityHelpLink:function(){return g}});var e=n(52322),c=n(90436),t=n(40303),r=n(2784),o=n(23196);function a(s){const{variant:l="gridItem",title:m,columns:x,entityKind:H,relationType:L,emptyMessage:R,emptyHelpLink:k,asRenderableEntities:S}=s,{entity:K}=(0,t.X2)(),{entities:M,loading:T,error:d}=(0,t.eK)(K,{type:L,kind:H});return T?(0,e.jsx)(o.rJ,{variant:l,title:m,children:(0,e.jsx)(o.Ex,{})}):d?(0,e.jsx)(o.rJ,{variant:l,title:m,children:(0,e.jsx)(o.Gk,{error:d})}):(0,e.jsx)(t.u3,{title:m,variant:l,emptyContent:(0,e.jsxs)("div",{style:{textAlign:"center"},children:[(0,e.jsx)(c.Z,{variant:"body1",children:R}),(0,e.jsx)(c.Z,{variant:"body2",children:(0,e.jsx)(o.rU,{to:k,children:"Learn how to change this."})})]}),columns:x,entities:S(M||[])})}const u=[t.u3.columns.createEntityRefColumn({defaultKind:"component"}),t.u3.columns.createOwnerColumn(),t.u3.columns.createSpecTypeColumn(),t.u3.columns.createSpecLifecycleColumn(),t.u3.columns.createMetadataDescriptionColumn()],y="https://backstage.io/docs/features/software-catalog/descriptor-format#kind-component",f=s=>s,C=[t.u3.columns.createEntityRefColumn({defaultKind:"resource"}),t.u3.columns.createOwnerColumn(),t.u3.columns.createSpecTypeColumn(),t.u3.columns.createSpecLifecycleColumn(),t.u3.columns.createMetadataDescriptionColumn()],E="https://backstage.io/docs/features/software-catalog/descriptor-format#kind-resource",h=s=>s,v=[t.u3.columns.createEntityRefColumn({defaultKind:"system"}),t.u3.columns.createOwnerColumn(),t.u3.columns.createMetadataDescriptionColumn()],g="https://backstage.io/docs/features/software-catalog/descriptor-format#kind-system",j=s=>s}}]);})();
2
2
 
3
- //# sourceMappingURL=1105.6191ca0a.chunk.js.map
3
+ //# sourceMappingURL=1105.0c932be4.chunk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"static/1105.6191ca0a.chunk.js","mappings":"0PA+BO,SAASA,EAAkBC,EAA+B,CAC/D,KAAM,CAAEC,QAAAA,EAAU,UAAW,EAAID,EACjC,SACE,OAACE,EAAAA,oBAAmBA,CAClBD,QAASA,EACTE,MAAM,iBACNC,WAAW,YACXC,aAAcC,EAAAA,GACdC,QAASC,EAAAA,uBACTC,aAAa,sCACbC,cAAeC,EAAAA,wBACfC,qBAAsBC,EAAAA,mB,EAG5B,C,mgBCYO,SAASX,EACdF,EACA,CACA,KAAM,CACJC,QAAAA,EAAU,WACVE,MAAAA,EACAI,QAAAA,EACAH,WAAAA,EACAC,aAAAA,EACAI,aAAAA,EACAC,cAAAA,EACAE,qBAAAA,CAAoB,EAClBZ,EAEE,CAAEc,OAAAA,CAAO,KAAIC,EAAAA,IAAU,EACvB,CAAEC,SAAAA,EAAUC,QAAAA,EAASC,MAAAA,CAAM,KAAIC,EAAAA,IAAmBL,EAAQ,CAC9DM,KAAMf,EACNgB,KAAMjB,CACR,CAAC,EAED,OAAIa,KAEA,OAACK,EAAAA,GA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ACX,oFACWC,EAAoBvB,GAC/BA,C","sources":["webpack://techdocs-cli-embedded-app/../../plugins/catalog/src/components/HasComponentsCard/HasComponentsCard.tsx","webpack://techdocs-cli-embedded-app/../../plugins/catalog/src/components/RelatedEntitiesCard/RelatedEntitiesCard.tsx","webpack://techdocs-cli-embedded-app/../../plugins/catalog/src/components/RelatedEntitiesCard/presets.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { RELATION_HAS_PART } from '@backstage/catalog-model';\nimport { InfoCardVariants } from '@backstage/core-components';\nimport React from 'react';\nimport {\n asComponentEntities,\n componentEntityColumns,\n componentEntityHelpLink,\n RelatedEntitiesCard,\n} from '../RelatedEntitiesCard';\n\n/** @public */\nexport interface HasComponentsCardProps {\n variant?: InfoCardVariants;\n}\n\nexport function HasComponentsCard(props: HasComponentsCardProps) {\n const { variant = 'gridItem' } = props;\n return (\n <RelatedEntitiesCard\n variant={variant}\n title=\"Has components\"\n entityKind=\"Component\"\n relationType={RELATION_HAS_PART}\n columns={componentEntityColumns}\n emptyMessage=\"No component is part of this system\"\n emptyHelpLink={componentEntityHelpLink}\n asRenderableEntities={asComponentEntities}\n />\n );\n}\n","/*\n * Copyright 2020 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 { Entity } from '@backstage/catalog-model';\nimport { Typography } from '@material-ui/core';\nimport {\n EntityTable,\n useEntity,\n useRelatedEntities,\n} from '@backstage/plugin-catalog-react';\nimport React from 'react';\nimport {\n InfoCard,\n InfoCardVariants,\n Link,\n Progress,\n ResponseErrorPanel,\n TableColumn,\n} from '@backstage/core-components';\n\n/** @public */\nexport type RelatedEntitiesCardProps<T extends Entity> = {\n variant?: InfoCardVariants;\n title: string;\n columns: TableColumn<T>[];\n entityKind?: string;\n relationType: string;\n emptyMessage: string;\n emptyHelpLink: string;\n asRenderableEntities: (entities: Entity[]) => T[];\n};\n\n/**\n * A low level card component that can be used as a building block for more\n * specific cards.\n *\n * @remarks\n *\n * You probably want to make a dedicated component for your needs, which renders\n * this card as its implementation with some of the props set to the appropriate\n * values.\n *\n * @public\n */\nexport function RelatedEntitiesCard<T extends Entity>(\n props: RelatedEntitiesCardProps<T>,\n) {\n const {\n variant = 'gridItem',\n title,\n columns,\n entityKind,\n relationType,\n emptyMessage,\n emptyHelpLink,\n asRenderableEntities,\n } = props;\n\n const { entity } = useEntity();\n const { entities, loading, error } = useRelatedEntities(entity, {\n type: relationType,\n kind: entityKind,\n });\n\n if (loading) {\n return (\n <InfoCard variant={variant} title={title}>\n <Progress />\n </InfoCard>\n );\n }\n\n if (error) {\n return (\n <InfoCard variant={variant} title={title}>\n <ResponseErrorPanel error={error} />\n </InfoCard>\n );\n }\n\n return (\n <EntityTable\n title={title}\n variant={variant}\n emptyContent={\n <div style={{ textAlign: 'center' }}>\n <Typography variant=\"body1\">{emptyMessage}</Typography>\n <Typography variant=\"body2\">\n <Link to={emptyHelpLink}>Learn how to change this.</Link>\n </Typography>\n </div>\n }\n columns={columns}\n entities={asRenderableEntities(entities || [])}\n />\n );\n}\n","/*\n * Copyright 2021 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 {\n ComponentEntity,\n Entity,\n ResourceEntity,\n SystemEntity,\n} from '@backstage/catalog-model';\nimport { EntityTable } from '@backstage/plugin-catalog-react';\nimport { TableColumn } from '@backstage/core-components';\n\nexport const componentEntityColumns: TableColumn<ComponentEntity>[] = [\n EntityTable.columns.createEntityRefColumn({ defaultKind: 'component' }),\n EntityTable.columns.createOwnerColumn(),\n EntityTable.columns.createSpecTypeColumn(),\n EntityTable.columns.createSpecLifecycleColumn(),\n EntityTable.columns.createMetadataDescriptionColumn(),\n];\nexport const componentEntityHelpLink: string =\n 'https://backstage.io/docs/features/software-catalog/descriptor-format#kind-component';\nexport const asComponentEntities = (entities: Entity[]): ComponentEntity[] =>\n entities as ComponentEntity[];\n\nexport const resourceEntityColumns: TableColumn<ResourceEntity>[] = [\n EntityTable.columns.createEntityRefColumn({ defaultKind: 'resource' }),\n EntityTable.columns.createOwnerColumn(),\n EntityTable.columns.createSpecTypeColumn(),\n EntityTable.columns.createSpecLifecycleColumn(),\n EntityTable.columns.createMetadataDescriptionColumn(),\n];\nexport const resourceEntityHelpLink: string =\n 'https://backstage.io/docs/features/software-catalog/descriptor-format#kind-resource';\nexport const asResourceEntities = (entities: Entity[]): ResourceEntity[] =>\n entities as ResourceEntity[];\n\nexport const systemEntityColumns: TableColumn<SystemEntity>[] = [\n EntityTable.columns.createEntityRefColumn({ defaultKind: 'system' }),\n EntityTable.columns.createOwnerColumn(),\n EntityTable.columns.createMetadataDescriptionColumn(),\n];\nexport const systemEntityHelpLink: string =\n 'https://backstage.io/docs/features/software-catalog/descriptor-format#kind-system';\nexport const asSystemEntities = (entities: Entity[]): SystemEntity[] =>\n entities as SystemEntity[];\n"],"names":["HasComponentsCard","props","variant","RelatedEntitiesCard","title","entityKind","relationType","RELATION_HAS_PART","columns","componentEntityColumns","emptyMessage","emptyHelpLink","componentEntityHelpLink","asRenderableEntities","asComponentEntities","entity","useEntity","entities","loading","error","useRelatedEntities","type","kind","InfoCard","Progress","ResponseErrorPanel","EntityTable","emptyContent","div","style","textAlign","Typography","Link","to","defaultKind","resourceEntityColumns","resourceEntityHelpLink","asResourceEntities","systemEntityColumns","systemEntityHelpLink","asSystemEntities"],"sourceRoot":""}
1
+ {"version":3,"file":"static/1105.0c932be4.chunk.js","mappings":"0PA+BO,SAASA,EAAkBC,EAA+B,CAC/D,KAAM,CAAEC,QAAAA,EAAU,UAAW,EAAID,EACjC,SACE,OAACE,EAAAA,oBAAmBA,CAClBD,QAASA,EACTE,MAAM,iBACNC,WAAW,YACXC,aAAcC,EAAAA,GACdC,QAASC,EAAAA,uBACTC,aAAa,sCACbC,cAAeC,EAAAA,wBACfC,qBAAsBC,EAAAA,mB,EAG5B,C,mgBCYO,SAASX,EACdF,EACA,CACA,KAAM,CACJC,QAAAA,EAAU,WACVE,MAAAA,EACAI,QAAAA,EACAH,WAAAA,EACAC,aAAAA,EACAI,aAAAA,EACAC,cAAAA,EACAE,qBAAAA,CAAoB,EAClBZ,EAEE,CAAEc,OAAAA,CAAO,KAAIC,EAAAA,IAAU,EACvB,CAAEC,SAAAA,EAAUC,QAAAA,EAASC,MAAAA,CAAM,KAAIC,EAAAA,IAAmBL,EAAQ,CAC9DM,KAAMf,EACNgB,KAAMjB,CACR,CAAC,EAED,OAAIa,KAEA,OAACK,EAAAA,GAAQA,CAACrB,QAASA,EAASE,MAAOA,E,YACjC,OAACoB,EAAAA,GAAQA,CAAAA,CAAAA,C,GAKXL,KAEA,OAACI,EAAAA,GAAQA,CAACrB,QAASA,EAASE,MAAOA,E,YACjC,OAACqB,EAAAA,GAAkBA,CAACN,MAAOA,C,QAM/B,OAACO,EAAAA,GAAWA,CACVtB,MAAOA,EACPF,QAASA,EACTyB,gBACE,QAACC,MAAAA,CAAIC,MAAO,CAAEC,UAAW,QAAS,E,aAChC,OAACC,EAAAA,EAAUA,CAAC7B,QAAQ,Q,SAASQ,C,MAC7B,OAACqB,EAAAA,EAAUA,CAAC7B,QAAQ,Q,YAClB,OAAC8B,EAAAA,GAAIA,CAACC,GAAItB,E,SAAe,2B,QAI/BH,QAASA,EACTS,SAAUJ,EAAqBI,GAAY,CAAC,CAAC,C,EAGnD,CCrFO,MAAMR,EAAyD,CACpEiB,EAAAA,GAAAA,QAAAA,sBAA0C,CAAEQ,YAAa,WAAY,CAAC,EACtER,EAAAA,GAAAA,QAAAA,kBAAsC,EACtCA,EAAAA,GAAAA,QAAAA,qBAAyC,EACzCA,EAAAA,GAAAA,QAAAA,0BAA8C,EAC9CA,EAAAA,GAAAA,QAAAA,gCAAoD,C,EAEzCd,EACX,uFACWE,EAAuBG,GAClCA,EAEWkB,EAAuD,CAClET,EAAAA,GAAAA,QAAAA,sBAA0C,CAAEQ,YAAa,UAAW,CAAC,EACrER,EAAAA,GAAAA,QAAAA,kBAAsC,EACtCA,EAAAA,GAAAA,QAAAA,qBAAyC,EACzCA,EAAAA,GAAAA,QAAAA,0BAA8C,EAC9CA,EAAAA,GAAAA,QAAAA,gCAAoD,C,EAEzCU,EACX,sFACWC,EAAsBpB,GACjCA,EAEWqB,EAAmD,CAC9DZ,EAAAA,GAAAA,QAAAA,sBAA0C,CAAEQ,YAAa,QAAS,CAAC,EACnER,EAAAA,GAAAA,QAAAA,kBAAsC,EACtCA,EAAAA,GAAAA,QAAAA,gCAAoD,C,EAEzCa,EACX,oFACWC,EAAoBvB,GAC/BA,C","sources":["webpack://techdocs-cli-embedded-app/../../plugins/catalog/src/components/HasComponentsCard/HasComponentsCard.tsx","webpack://techdocs-cli-embedded-app/../../plugins/catalog/src/components/RelatedEntitiesCard/RelatedEntitiesCard.tsx","webpack://techdocs-cli-embedded-app/../../plugins/catalog/src/components/RelatedEntitiesCard/presets.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { RELATION_HAS_PART } from '@backstage/catalog-model';\nimport { InfoCardVariants } from '@backstage/core-components';\nimport React from 'react';\nimport {\n asComponentEntities,\n componentEntityColumns,\n componentEntityHelpLink,\n RelatedEntitiesCard,\n} from '../RelatedEntitiesCard';\n\n/** @public */\nexport interface HasComponentsCardProps {\n variant?: InfoCardVariants;\n}\n\nexport function HasComponentsCard(props: HasComponentsCardProps) {\n const { variant = 'gridItem' } = props;\n return (\n <RelatedEntitiesCard\n variant={variant}\n title=\"Has components\"\n entityKind=\"Component\"\n relationType={RELATION_HAS_PART}\n columns={componentEntityColumns}\n emptyMessage=\"No component is part of this system\"\n emptyHelpLink={componentEntityHelpLink}\n asRenderableEntities={asComponentEntities}\n />\n );\n}\n","/*\n * Copyright 2020 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 { Entity } from '@backstage/catalog-model';\nimport { Typography } from '@material-ui/core';\nimport {\n EntityTable,\n useEntity,\n useRelatedEntities,\n} from '@backstage/plugin-catalog-react';\nimport React from 'react';\nimport {\n InfoCard,\n InfoCardVariants,\n Link,\n Progress,\n ResponseErrorPanel,\n TableColumn,\n} from '@backstage/core-components';\n\n/** @public */\nexport type RelatedEntitiesCardProps<T extends Entity> = {\n variant?: InfoCardVariants;\n title: string;\n columns: TableColumn<T>[];\n entityKind?: string;\n relationType: string;\n emptyMessage: string;\n emptyHelpLink: string;\n asRenderableEntities: (entities: Entity[]) => T[];\n};\n\n/**\n * A low level card component that can be used as a building block for more\n * specific cards.\n *\n * @remarks\n *\n * You probably want to make a dedicated component for your needs, which renders\n * this card as its implementation with some of the props set to the appropriate\n * values.\n *\n * @public\n */\nexport function RelatedEntitiesCard<T extends Entity>(\n props: RelatedEntitiesCardProps<T>,\n) {\n const {\n variant = 'gridItem',\n title,\n columns,\n entityKind,\n relationType,\n emptyMessage,\n emptyHelpLink,\n asRenderableEntities,\n } = props;\n\n const { entity } = useEntity();\n const { entities, loading, error } = useRelatedEntities(entity, {\n type: relationType,\n kind: entityKind,\n });\n\n if (loading) {\n return (\n <InfoCard variant={variant} title={title}>\n <Progress />\n </InfoCard>\n );\n }\n\n if (error) {\n return (\n <InfoCard variant={variant} title={title}>\n <ResponseErrorPanel error={error} />\n </InfoCard>\n );\n }\n\n return (\n <EntityTable\n title={title}\n variant={variant}\n emptyContent={\n <div style={{ textAlign: 'center' }}>\n <Typography variant=\"body1\">{emptyMessage}</Typography>\n <Typography variant=\"body2\">\n <Link to={emptyHelpLink}>Learn how to change this.</Link>\n </Typography>\n </div>\n }\n columns={columns}\n entities={asRenderableEntities(entities || [])}\n />\n );\n}\n","/*\n * Copyright 2021 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 {\n ComponentEntity,\n Entity,\n ResourceEntity,\n SystemEntity,\n} from '@backstage/catalog-model';\nimport { EntityTable } from '@backstage/plugin-catalog-react';\nimport { TableColumn } from '@backstage/core-components';\n\nexport const componentEntityColumns: TableColumn<ComponentEntity>[] = [\n EntityTable.columns.createEntityRefColumn({ defaultKind: 'component' }),\n EntityTable.columns.createOwnerColumn(),\n EntityTable.columns.createSpecTypeColumn(),\n EntityTable.columns.createSpecLifecycleColumn(),\n EntityTable.columns.createMetadataDescriptionColumn(),\n];\nexport const componentEntityHelpLink: string =\n 'https://backstage.io/docs/features/software-catalog/descriptor-format#kind-component';\nexport const asComponentEntities = (entities: Entity[]): ComponentEntity[] =>\n entities as ComponentEntity[];\n\nexport const resourceEntityColumns: TableColumn<ResourceEntity>[] = [\n EntityTable.columns.createEntityRefColumn({ defaultKind: 'resource' }),\n EntityTable.columns.createOwnerColumn(),\n EntityTable.columns.createSpecTypeColumn(),\n EntityTable.columns.createSpecLifecycleColumn(),\n EntityTable.columns.createMetadataDescriptionColumn(),\n];\nexport const resourceEntityHelpLink: string =\n 'https://backstage.io/docs/features/software-catalog/descriptor-format#kind-resource';\nexport const asResourceEntities = (entities: Entity[]): ResourceEntity[] =>\n entities as ResourceEntity[];\n\nexport const systemEntityColumns: TableColumn<SystemEntity>[] = [\n EntityTable.columns.createEntityRefColumn({ defaultKind: 'system' }),\n EntityTable.columns.createOwnerColumn(),\n EntityTable.columns.createMetadataDescriptionColumn(),\n];\nexport const systemEntityHelpLink: string =\n 'https://backstage.io/docs/features/software-catalog/descriptor-format#kind-system';\nexport const asSystemEntities = (entities: Entity[]): SystemEntity[] =>\n entities as SystemEntity[];\n"],"names":["HasComponentsCard","props","variant","RelatedEntitiesCard","title","entityKind","relationType","RELATION_HAS_PART","columns","componentEntityColumns","emptyMessage","emptyHelpLink","componentEntityHelpLink","asRenderableEntities","asComponentEntities","entity","useEntity","entities","loading","error","useRelatedEntities","type","kind","InfoCard","Progress","ResponseErrorPanel","EntityTable","emptyContent","div","style","textAlign","Typography","Link","to","defaultKind","resourceEntityColumns","resourceEntityHelpLink","asResourceEntities","systemEntityColumns","systemEntityHelpLink","asSystemEntities"],"sourceRoot":""}
@@ -1,3 +1,3 @@
1
1
  "use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[184,732],{40184:function(y,i,n){n.r(i),n.d(i,{DependencyOfComponentsCard:function(){return o}});var e=n(52322),r=n(25271),t=n(2784),c=n(732);function o(a){const{variant:u="gridItem",title:l="Dependency of components"}=a;return(0,e.jsx)(c.RelatedEntitiesCard,{variant:u,title:l,entityKind:"Component",relationType:r.w$,columns:c.componentEntityColumns,emptyMessage:"No component depends on this component",emptyHelpLink:c.componentEntityHelpLink,asRenderableEntities:c.asComponentEntities})}},732:function(y,i,n){n.r(i),n.d(i,{RelatedEntitiesCard:function(){return a},asComponentEntities:function(){return f},asResourceEntities:function(){return h},asSystemEntities:function(){return j},componentEntityColumns:function(){return u},componentEntityHelpLink:function(){return l},resourceEntityColumns:function(){return C},resourceEntityHelpLink:function(){return E},systemEntityColumns:function(){return v},systemEntityHelpLink:function(){return g}});var e=n(52322),r=n(90436),t=n(40303),c=n(2784),o=n(23196);function a(s){const{variant:m="gridItem",title:d,columns:x,entityKind:L,relationType:R,emptyMessage:k,emptyHelpLink:H,asRenderableEntities:D}=s,{entity:K}=(0,t.X2)(),{entities:S,loading:M,error:p}=(0,t.eK)(K,{type:R,kind:L});return M?(0,e.jsx)(o.rJ,{variant:m,title:d,children:(0,e.jsx)(o.Ex,{})}):p?(0,e.jsx)(o.rJ,{variant:m,title:d,children:(0,e.jsx)(o.Gk,{error:p})}):(0,e.jsx)(t.u3,{title:d,variant:m,emptyContent:(0,e.jsxs)("div",{style:{textAlign:"center"},children:[(0,e.jsx)(r.Z,{variant:"body1",children:k}),(0,e.jsx)(r.Z,{variant:"body2",children:(0,e.jsx)(o.rU,{to:H,children:"Learn how to change this."})})]}),columns:x,entities:D(S||[])})}const u=[t.u3.columns.createEntityRefColumn({defaultKind:"component"}),t.u3.columns.createOwnerColumn(),t.u3.columns.createSpecTypeColumn(),t.u3.columns.createSpecLifecycleColumn(),t.u3.columns.createMetadataDescriptionColumn()],l="https://backstage.io/docs/features/software-catalog/descriptor-format#kind-component",f=s=>s,C=[t.u3.columns.createEntityRefColumn({defaultKind:"resource"}),t.u3.columns.createOwnerColumn(),t.u3.columns.createSpecTypeColumn(),t.u3.columns.createSpecLifecycleColumn(),t.u3.columns.createMetadataDescriptionColumn()],E="https://backstage.io/docs/features/software-catalog/descriptor-format#kind-resource",h=s=>s,v=[t.u3.columns.createEntityRefColumn({defaultKind:"system"}),t.u3.columns.createOwnerColumn(),t.u3.columns.createMetadataDescriptionColumn()],g="https://backstage.io/docs/features/software-catalog/descriptor-format#kind-system",j=s=>s}}]);})();
2
2
 
3
- //# sourceMappingURL=184.26a4caf6.chunk.js.map
3
+ //# sourceMappingURL=184.0de82ef1.chunk.js.map