@backstage/plugin-techdocs-node 1.12.12-next.1 → 1.12.12

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 (43) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/extensions.cjs.js +22 -0
  3. package/dist/extensions.cjs.js.map +1 -0
  4. package/dist/helpers.cjs.js +80 -0
  5. package/dist/helpers.cjs.js.map +1 -0
  6. package/dist/index.cjs.js +29 -2602
  7. package/dist/index.cjs.js.map +1 -1
  8. package/dist/index.d.ts +11 -1
  9. package/dist/stages/generate/DockerContainerRunner.cjs.js +99 -0
  10. package/dist/stages/generate/DockerContainerRunner.cjs.js.map +1 -0
  11. package/dist/stages/generate/generators.cjs.js +42 -0
  12. package/dist/stages/generate/generators.cjs.js.map +1 -0
  13. package/dist/stages/generate/helpers.cjs.js +265 -0
  14. package/dist/stages/generate/helpers.cjs.js.map +1 -0
  15. package/dist/stages/generate/index.cjs.js +15 -0
  16. package/dist/stages/generate/index.cjs.js.map +1 -0
  17. package/dist/stages/generate/mkdocsPatchers.cjs.js +96 -0
  18. package/dist/stages/generate/mkdocsPatchers.cjs.js.map +1 -0
  19. package/dist/stages/generate/techdocs.cjs.js +169 -0
  20. package/dist/stages/generate/techdocs.cjs.js.map +1 -0
  21. package/dist/stages/prepare/dir.cjs.js +63 -0
  22. package/dist/stages/prepare/dir.cjs.js.map +1 -0
  23. package/dist/stages/prepare/preparers.cjs.js +54 -0
  24. package/dist/stages/prepare/preparers.cjs.js.map +1 -0
  25. package/dist/stages/prepare/url.cjs.js +46 -0
  26. package/dist/stages/prepare/url.cjs.js.map +1 -0
  27. package/dist/stages/publish/awsS3.cjs.js +436 -0
  28. package/dist/stages/publish/awsS3.cjs.js.map +1 -0
  29. package/dist/stages/publish/azureBlobStorage.cjs.js +337 -0
  30. package/dist/stages/publish/azureBlobStorage.cjs.js.map +1 -0
  31. package/dist/stages/publish/googleStorage.cjs.js +288 -0
  32. package/dist/stages/publish/googleStorage.cjs.js.map +1 -0
  33. package/dist/stages/publish/helpers.cjs.js +138 -0
  34. package/dist/stages/publish/helpers.cjs.js.map +1 -0
  35. package/dist/stages/publish/local.cjs.js +248 -0
  36. package/dist/stages/publish/local.cjs.js.map +1 -0
  37. package/dist/stages/publish/migrations/GoogleMigration.cjs.js +52 -0
  38. package/dist/stages/publish/migrations/GoogleMigration.cjs.js.map +1 -0
  39. package/dist/stages/publish/openStackSwift.cjs.js +286 -0
  40. package/dist/stages/publish/openStackSwift.cjs.js.map +1 -0
  41. package/dist/stages/publish/publish.cjs.js +100 -0
  42. package/dist/stages/publish/publish.cjs.js.map +1 -0
  43. package/package.json +13 -13
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @backstage/plugin-techdocs-node
2
2
 
3
+ ## 1.12.12
4
+
5
+ ### Patch Changes
6
+
7
+ - 7774828: Updated dependency `@smithy/node-http-handler` to `^3.0.0`.
8
+ - 720a2f9: Updated dependency `git-url-parse` to `^15.0.0`.
9
+ - fbdc631: Allow to pass StorageOptions to GCS Publisher
10
+ - Updated dependencies
11
+ - @backstage/integration@1.15.1
12
+ - @backstage/backend-plugin-api@1.0.1
13
+ - @backstage/catalog-model@1.7.0
14
+ - @backstage/config@1.2.0
15
+ - @backstage/errors@1.2.4
16
+ - @backstage/integration-aws-node@0.1.12
17
+ - @backstage/plugin-search-common@1.2.14
18
+ - @backstage/plugin-techdocs-common@0.1.0
19
+
20
+ ## 1.12.12-next.2
21
+
22
+ ### Patch Changes
23
+
24
+ - 7774828: Updated dependency `@smithy/node-http-handler` to `^3.0.0`.
25
+ - 720a2f9: Updated dependency `git-url-parse` to `^15.0.0`.
26
+ - fbdc631: Allow to pass StorageOptions to GCS Publisher
27
+ - Updated dependencies
28
+ - @backstage/integration@1.15.1-next.1
29
+ - @backstage/backend-plugin-api@1.0.1-next.1
30
+ - @backstage/catalog-model@1.7.0
31
+ - @backstage/config@1.2.0
32
+ - @backstage/errors@1.2.4
33
+ - @backstage/integration-aws-node@0.1.12
34
+ - @backstage/plugin-search-common@1.2.14
35
+ - @backstage/plugin-techdocs-common@0.1.0
36
+
3
37
  ## 1.12.12-next.1
4
38
 
5
39
  ### Patch Changes
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var backendPluginApi = require('@backstage/backend-plugin-api');
4
+
5
+ const techdocsBuildsExtensionPoint = backendPluginApi.createExtensionPoint({
6
+ id: "techdocs.builds"
7
+ });
8
+ const techdocsGeneratorExtensionPoint = backendPluginApi.createExtensionPoint({
9
+ id: "techdocs.generator"
10
+ });
11
+ const techdocsPreparerExtensionPoint = backendPluginApi.createExtensionPoint({
12
+ id: "techdocs.preparer"
13
+ });
14
+ const techdocsPublisherExtensionPoint = backendPluginApi.createExtensionPoint({
15
+ id: "techdocs.publisher"
16
+ });
17
+
18
+ exports.techdocsBuildsExtensionPoint = techdocsBuildsExtensionPoint;
19
+ exports.techdocsGeneratorExtensionPoint = techdocsGeneratorExtensionPoint;
20
+ exports.techdocsPreparerExtensionPoint = techdocsPreparerExtensionPoint;
21
+ exports.techdocsPublisherExtensionPoint = techdocsPublisherExtensionPoint;
22
+ //# sourceMappingURL=extensions.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensions.cjs.js","sources":["../src/extensions.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport { DocsBuildStrategy } from './techdocsTypes';\nimport {\n PreparerBase,\n PublisherBase,\n PublisherType,\n RemoteProtocol,\n TechdocsGenerator,\n} from './stages';\nimport * as winston from 'winston';\nimport { PublisherSettings } from './stages/publish/types';\n\n/**\n * Extension point type for configuring TechDocs builds.\n *\n * @public\n */\nexport interface TechdocsBuildsExtensionPoint {\n setBuildStrategy(buildStrategy: DocsBuildStrategy): void;\n setBuildLogTransport(transport: winston.transport): void;\n}\n\n/**\n * Extension point for configuring TechDocs builds.\n *\n * @public\n */\nexport const techdocsBuildsExtensionPoint =\n createExtensionPoint<TechdocsBuildsExtensionPoint>({\n id: 'techdocs.builds',\n });\n\n/**\n * Extension point type for configuring a custom TechDocs generator\n *\n * @public\n */\nexport interface TechdocsGeneratorExtensionPoint {\n setTechdocsGenerator(generator: TechdocsGenerator): void;\n}\n\n/**\n * Extension point for configuring a custom TechDocs generator\n *\n * @public\n */\nexport const techdocsGeneratorExtensionPoint =\n createExtensionPoint<TechdocsGeneratorExtensionPoint>({\n id: 'techdocs.generator',\n });\n\n/**\n * Extension point type for configuring a custom TechDocs preparer\n *\n * @public\n */\nexport interface TechdocsPreparerExtensionPoint {\n registerPreparer(protocol: RemoteProtocol, preparer: PreparerBase): void;\n}\n\n/**\n * Extension point for configuring a custom TechDocs preparer\n *\n * @public\n */\nexport const techdocsPreparerExtensionPoint =\n createExtensionPoint<TechdocsPreparerExtensionPoint>({\n id: 'techdocs.preparer',\n });\n\n/**\n * Extension point type for configuring a custom TechDocs publisher\n *\n * @public\n */\nexport interface TechdocsPublisherExtensionPoint {\n registerPublisher(type: PublisherType, publisher: PublisherBase): void;\n registerPublisherSettings<T extends keyof PublisherSettings>(\n publisher: T,\n settings: PublisherSettings[T],\n ): void;\n}\n\n/**\n * Extension point for configuring a custom TechDocs publisher\n *\n * @public\n */\nexport const techdocsPublisherExtensionPoint =\n createExtensionPoint<TechdocsPublisherExtensionPoint>({\n id: 'techdocs.publisher',\n });\n"],"names":["createExtensionPoint"],"mappings":";;;;AA0CO,MAAM,+BACXA,qCAAmD,CAAA;AAAA,EACjD,EAAI,EAAA,iBAAA;AACN,CAAC,EAAA;AAgBI,MAAM,kCACXA,qCAAsD,CAAA;AAAA,EACpD,EAAI,EAAA,oBAAA;AACN,CAAC,EAAA;AAgBI,MAAM,iCACXA,qCAAqD,CAAA;AAAA,EACnD,EAAI,EAAA,mBAAA;AACN,CAAC,EAAA;AAoBI,MAAM,kCACXA,qCAAsD,CAAA;AAAA,EACpD,EAAI,EAAA,oBAAA;AACN,CAAC;;;;;;;"}
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ var backendPluginApi = require('@backstage/backend-plugin-api');
4
+ var catalogModel = require('@backstage/catalog-model');
5
+ var errors = require('@backstage/errors');
6
+ var pluginTechdocsCommon = require('@backstage/plugin-techdocs-common');
7
+ var path = require('path');
8
+
9
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
10
+
11
+ var path__default = /*#__PURE__*/_interopDefaultCompat(path);
12
+
13
+ const parseReferenceAnnotation = (annotationName, entity) => {
14
+ const annotation = entity.metadata.annotations?.[annotationName];
15
+ if (!annotation) {
16
+ throw new errors.InputError(
17
+ `No location annotation provided in entity: ${entity.metadata.name}`
18
+ );
19
+ }
20
+ const { type, target } = catalogModel.parseLocationRef(annotation);
21
+ return {
22
+ type,
23
+ target
24
+ };
25
+ };
26
+ const transformDirLocation = (entity, dirAnnotation, scmIntegrations) => {
27
+ const location = catalogModel.getEntitySourceLocation(entity);
28
+ switch (location.type) {
29
+ case "url": {
30
+ const target = scmIntegrations.resolveUrl({
31
+ url: dirAnnotation.target,
32
+ base: location.target
33
+ });
34
+ return {
35
+ type: "url",
36
+ target
37
+ };
38
+ }
39
+ case "file": {
40
+ const target = backendPluginApi.resolveSafeChildPath(
41
+ path__default.default.dirname(location.target),
42
+ dirAnnotation.target
43
+ );
44
+ return {
45
+ type: "dir",
46
+ target
47
+ };
48
+ }
49
+ default:
50
+ throw new errors.InputError(`Unable to resolve location type ${location.type}`);
51
+ }
52
+ };
53
+ const getLocationForEntity = (entity, scmIntegration) => {
54
+ const annotation = parseReferenceAnnotation(pluginTechdocsCommon.TECHDOCS_ANNOTATION, entity);
55
+ switch (annotation.type) {
56
+ case "url":
57
+ return annotation;
58
+ case "dir":
59
+ return transformDirLocation(entity, annotation, scmIntegration);
60
+ default:
61
+ throw new Error(`Invalid reference annotation ${annotation.type}`);
62
+ }
63
+ };
64
+ const getDocFilesFromRepository = async (reader, entity, opts) => {
65
+ const { target } = parseReferenceAnnotation(pluginTechdocsCommon.TECHDOCS_ANNOTATION, entity);
66
+ opts?.logger?.debug(`Reading files from ${target}`);
67
+ const readTreeResponse = await reader.readTree(target, { etag: opts?.etag });
68
+ const preparedDir = await readTreeResponse.dir();
69
+ opts?.logger?.debug(`Tree downloaded and stored at ${preparedDir}`);
70
+ return {
71
+ preparedDir,
72
+ etag: readTreeResponse.etag
73
+ };
74
+ };
75
+
76
+ exports.getDocFilesFromRepository = getDocFilesFromRepository;
77
+ exports.getLocationForEntity = getLocationForEntity;
78
+ exports.parseReferenceAnnotation = parseReferenceAnnotation;
79
+ exports.transformDirLocation = transformDirLocation;
80
+ //# sourceMappingURL=helpers.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.cjs.js","sources":["../src/helpers.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 {\n LoggerService,\n UrlReaderService,\n resolveSafeChildPath,\n} from '@backstage/backend-plugin-api';\nimport {\n Entity,\n getEntitySourceLocation,\n parseLocationRef,\n} from '@backstage/catalog-model';\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { TECHDOCS_ANNOTATION } from '@backstage/plugin-techdocs-common';\nimport path from 'path';\nimport { PreparerResponse, RemoteProtocol } from './stages/prepare/types';\n\n/**\n * Parsed location annotation\n * @public\n */\nexport type ParsedLocationAnnotation = {\n type: RemoteProtocol;\n target: string;\n};\n\n/**\n * Returns a parsed locations annotation\n * @public\n * @param annotationName - The name of the annotation in the entity metadata\n * @param entity - A TechDocs entity instance\n */\nexport const parseReferenceAnnotation = (\n annotationName: string,\n entity: Entity,\n): ParsedLocationAnnotation => {\n const annotation = entity.metadata.annotations?.[annotationName];\n if (!annotation) {\n throw new InputError(\n `No location annotation provided in entity: ${entity.metadata.name}`,\n );\n }\n\n const { type, target } = parseLocationRef(annotation);\n return {\n type: type as RemoteProtocol,\n target,\n };\n};\n\n/**\n * TechDocs references of type `dir` are relative the source location of the entity.\n * This function transforms relative references to absolute ones, based on the\n * location the entity was ingested from. If the entity was registered by a `url`\n * location, it returns a `url` location with a resolved target that points to the\n * targeted subfolder. If the entity was registered by a `file` location, it returns\n * an absolute `dir` location.\n * @public\n * @param entity - the entity with annotations\n * @param dirAnnotation - the parsed techdocs-ref annotation of type 'dir'\n * @param scmIntegrations - access to the scmIntegration to do url transformations\n * @throws if the entity doesn't specify a `dir` location or is ingested from an unsupported location.\n * @returns the transformed location with an absolute target.\n */\nexport const transformDirLocation = (\n entity: Entity,\n dirAnnotation: ParsedLocationAnnotation,\n scmIntegrations: ScmIntegrationRegistry,\n): { type: 'dir' | 'url'; target: string } => {\n const location = getEntitySourceLocation(entity);\n\n switch (location.type) {\n case 'url': {\n const target = scmIntegrations.resolveUrl({\n url: dirAnnotation.target,\n base: location.target,\n });\n\n return {\n type: 'url',\n target,\n };\n }\n\n case 'file': {\n // only permit targets in the same folder as the target of the `file` location!\n const target = resolveSafeChildPath(\n path.dirname(location.target),\n dirAnnotation.target,\n );\n\n return {\n type: 'dir',\n target,\n };\n }\n\n default:\n throw new InputError(`Unable to resolve location type ${location.type}`);\n }\n};\n\n/**\n * Returns an entity reference based on the TechDocs annotation type\n * @public\n * @param entity - A TechDocs instance\n * @param scmIntegration - An implementation for SCM integration API\n */\nexport const getLocationForEntity = (\n entity: Entity,\n scmIntegration: ScmIntegrationRegistry,\n): ParsedLocationAnnotation => {\n const annotation = parseReferenceAnnotation(TECHDOCS_ANNOTATION, entity);\n\n switch (annotation.type) {\n case 'url':\n return annotation;\n case 'dir':\n return transformDirLocation(entity, annotation, scmIntegration);\n default:\n throw new Error(`Invalid reference annotation ${annotation.type}`);\n }\n};\n\n/**\n * Returns a preparer response {@link PreparerResponse}\n * @public\n * @param reader - Read a tree of files from a repository\n * @param entity - A TechDocs entity instance\n * @param opts - Options for configuring the reader, e.g. logger, etag, etc.\n */\nexport const getDocFilesFromRepository = async (\n reader: UrlReaderService,\n entity: Entity,\n opts?: { etag?: string; logger?: LoggerService },\n): Promise<PreparerResponse> => {\n const { target } = parseReferenceAnnotation(TECHDOCS_ANNOTATION, entity);\n\n opts?.logger?.debug(`Reading files from ${target}`);\n // readTree will throw NotModifiedError if etag has not changed.\n const readTreeResponse = await reader.readTree(target, { etag: opts?.etag });\n const preparedDir = await readTreeResponse.dir();\n\n opts?.logger?.debug(`Tree downloaded and stored at ${preparedDir}`);\n\n return {\n preparedDir,\n etag: readTreeResponse.etag,\n };\n};\n"],"names":["InputError","parseLocationRef","getEntitySourceLocation","resolveSafeChildPath","path","TECHDOCS_ANNOTATION"],"mappings":";;;;;;;;;;;;AA+Ca,MAAA,wBAAA,GAA2B,CACtC,cAAA,EACA,MAC6B,KAAA;AAC7B,EAAA,MAAM,UAAa,GAAA,MAAA,CAAO,QAAS,CAAA,WAAA,GAAc,cAAc,CAAA,CAAA;AAC/D,EAAA,IAAI,CAAC,UAAY,EAAA;AACf,IAAA,MAAM,IAAIA,iBAAA;AAAA,MACR,CAAA,2CAAA,EAA8C,MAAO,CAAA,QAAA,CAAS,IAAI,CAAA,CAAA;AAAA,KACpE,CAAA;AAAA,GACF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