@backstage/plugin-techdocs-node 1.12.4-next.2 → 1.12.5-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/index.cjs.js +87 -177
- package/dist/index.cjs.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @backstage/plugin-techdocs-node
|
|
2
2
|
|
|
3
|
+
## 1.12.5-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/backend-common@0.22.1-next.0
|
|
9
|
+
- @backstage/backend-plugin-api@0.6.19-next.0
|
|
10
|
+
- @backstage/catalog-model@1.5.0
|
|
11
|
+
- @backstage/config@1.2.0
|
|
12
|
+
- @backstage/errors@1.2.4
|
|
13
|
+
- @backstage/integration@1.11.0
|
|
14
|
+
- @backstage/integration-aws-node@0.1.12
|
|
15
|
+
- @backstage/plugin-search-common@1.2.11
|
|
16
|
+
|
|
17
|
+
## 1.12.4
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- d229dc4: Move path utilities from `backend-common` to the `backend-plugin-api` package.
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @backstage/catalog-model@1.5.0
|
|
24
|
+
- @backstage/backend-common@0.22.0
|
|
25
|
+
- @backstage/backend-plugin-api@0.6.18
|
|
26
|
+
- @backstage/integration@1.11.0
|
|
27
|
+
|
|
3
28
|
## 1.12.4-next.2
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var path = require('path');
|
|
4
4
|
var integration = require('@backstage/integration');
|
|
5
|
-
var
|
|
5
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
6
6
|
var errors = require('@backstage/errors');
|
|
7
7
|
var child_process = require('child_process');
|
|
8
8
|
var fs = require('fs-extra');
|
|
@@ -27,7 +27,6 @@ var express = require('express');
|
|
|
27
27
|
var os = require('os');
|
|
28
28
|
var openstackSwiftSdk = require('@trendyol-js/openstack-swift-sdk');
|
|
29
29
|
var types = require('@trendyol-js/openstack-swift-sdk/lib/types');
|
|
30
|
-
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
31
30
|
|
|
32
31
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
33
32
|
|
|
@@ -108,9 +107,8 @@ const getStaleFiles = (newFiles, oldFiles) => {
|
|
|
108
107
|
return Array.from(staleFiles);
|
|
109
108
|
};
|
|
110
109
|
const getCloudPathForLocalPath = (entity, localPath = "", useLegacyPathCasing = false, externalStorageRootPath = "") => {
|
|
111
|
-
var _a, _b;
|
|
112
110
|
const relativeFilePathPosix = localPath.split(path__default.default.sep).join(path__default.default.posix.sep);
|
|
113
|
-
const entityRootDir = `${
|
|
111
|
+
const entityRootDir = `${entity.metadata?.namespace ?? catalogModel.DEFAULT_NAMESPACE}/${entity.kind}/${entity.metadata.name}`;
|
|
114
112
|
const relativeFilePathTriplet = `${entityRootDir}/${relativeFilePathPosix}`;
|
|
115
113
|
const destination = useLegacyPathCasing ? relativeFilePathTriplet : lowerCaseEntityTriplet(relativeFilePathTriplet);
|
|
116
114
|
const destinationWithRoot = [
|
|
@@ -188,10 +186,7 @@ const MKDOCS_SCHEMA = yaml.DEFAULT_SCHEMA.extend([
|
|
|
188
186
|
kind: "scalar",
|
|
189
187
|
multi: true,
|
|
190
188
|
representName: (o) => o.type,
|
|
191
|
-
represent: (o) =>
|
|
192
|
-
var _a;
|
|
193
|
-
return (_a = o.data) != null ? _a : "";
|
|
194
|
-
},
|
|
189
|
+
represent: (o) => o.data ?? "",
|
|
195
190
|
instanceOf: UnknownTag,
|
|
196
191
|
construct: (data, type) => new UnknownTag(data, type)
|
|
197
192
|
}),
|
|
@@ -199,19 +194,15 @@ const MKDOCS_SCHEMA = yaml.DEFAULT_SCHEMA.extend([
|
|
|
199
194
|
kind: "sequence",
|
|
200
195
|
multi: true,
|
|
201
196
|
representName: (o) => o.type,
|
|
202
|
-
represent: (o) =>
|
|
203
|
-
var _a;
|
|
204
|
-
return (_a = o.data) != null ? _a : "";
|
|
205
|
-
},
|
|
197
|
+
represent: (o) => o.data ?? "",
|
|
206
198
|
instanceOf: UnknownTag,
|
|
207
199
|
construct: (data, type) => new UnknownTag(data, type)
|
|
208
200
|
})
|
|
209
201
|
]);
|
|
210
202
|
const generateMkdocsYml = async (inputDir, siteOptions) => {
|
|
211
|
-
var _a;
|
|
212
203
|
try {
|
|
213
204
|
const mkdocsYmlPath = path__default.default.join(inputDir, "mkdocs.yml");
|
|
214
|
-
const defaultSiteName =
|
|
205
|
+
const defaultSiteName = siteOptions?.name ?? "Documentation Site";
|
|
215
206
|
const defaultMkdocsContent = {
|
|
216
207
|
site_name: defaultSiteName,
|
|
217
208
|
docs_dir: "docs",
|
|
@@ -229,7 +220,7 @@ const getMkdocsYml = async (inputDir, options) => {
|
|
|
229
220
|
let mkdocsYmlPath;
|
|
230
221
|
let mkdocsYmlFileString;
|
|
231
222
|
try {
|
|
232
|
-
if (options
|
|
223
|
+
if (options?.mkdocsConfigFileName) {
|
|
233
224
|
mkdocsYmlPath = path__default.default.join(inputDir, options.mkdocsConfigFileName);
|
|
234
225
|
if (!await fs__default.default.pathExists(mkdocsYmlPath)) {
|
|
235
226
|
throw new Error(`The specified file ${mkdocsYmlPath} does not exist`);
|
|
@@ -281,7 +272,7 @@ const validateMkdocsYaml = async (inputDir, mkdocsYmlFileString) => {
|
|
|
281
272
|
return void 0;
|
|
282
273
|
}
|
|
283
274
|
const parsedMkdocsYml = mkdocsYml;
|
|
284
|
-
if (parsedMkdocsYml.docs_dir && !
|
|
275
|
+
if (parsedMkdocsYml.docs_dir && !backendPluginApi.isChildPath(inputDir, path.resolve(inputDir, parsedMkdocsYml.docs_dir))) {
|
|
285
276
|
throw new Error(
|
|
286
277
|
`docs_dir configuration value in mkdocs can't be an absolute directory or start with ../ for security reasons.
|
|
287
278
|
Use relative paths instead which are resolved relative to your mkdocs.yml file location.`
|
|
@@ -438,23 +429,16 @@ const patchMkdocsYmlWithPlugins = async (mkdocsYmlPath, logger, defaultPlugins =
|
|
|
438
429
|
});
|
|
439
430
|
};
|
|
440
431
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
__publicField$a(this, "options");
|
|
452
|
-
__publicField$a(this, "scmIntegrations");
|
|
453
|
-
this.logger = options.logger;
|
|
454
|
-
this.options = readGeneratorConfig(options.config, options.logger);
|
|
455
|
-
this.containerRunner = options.containerRunner;
|
|
456
|
-
this.scmIntegrations = options.scmIntegrations;
|
|
457
|
-
}
|
|
432
|
+
class TechdocsGenerator {
|
|
433
|
+
/**
|
|
434
|
+
* The default docker image (and version) used to generate content. Public
|
|
435
|
+
* and static so that techdocs-node consumers can use the same version.
|
|
436
|
+
*/
|
|
437
|
+
static defaultDockerImage = "spotify/techdocs:v1.2.3";
|
|
438
|
+
logger;
|
|
439
|
+
containerRunner;
|
|
440
|
+
options;
|
|
441
|
+
scmIntegrations;
|
|
458
442
|
/**
|
|
459
443
|
* Returns a instance of TechDocs generator
|
|
460
444
|
* @param config - A Backstage configuration
|
|
@@ -463,16 +447,21 @@ const _TechdocsGenerator = class _TechdocsGenerator {
|
|
|
463
447
|
static fromConfig(config, options) {
|
|
464
448
|
const { containerRunner, logger } = options;
|
|
465
449
|
const scmIntegrations = integration.ScmIntegrations.fromConfig(config);
|
|
466
|
-
return new
|
|
450
|
+
return new TechdocsGenerator({
|
|
467
451
|
logger,
|
|
468
452
|
containerRunner,
|
|
469
453
|
config,
|
|
470
454
|
scmIntegrations
|
|
471
455
|
});
|
|
472
456
|
}
|
|
457
|
+
constructor(options) {
|
|
458
|
+
this.logger = options.logger;
|
|
459
|
+
this.options = readGeneratorConfig(options.config, options.logger);
|
|
460
|
+
this.containerRunner = options.containerRunner;
|
|
461
|
+
this.scmIntegrations = options.scmIntegrations;
|
|
462
|
+
}
|
|
473
463
|
/** {@inheritDoc GeneratorBase.run} */
|
|
474
464
|
async run(options) {
|
|
475
|
-
var _a, _b;
|
|
476
465
|
const {
|
|
477
466
|
inputDir,
|
|
478
467
|
outputDir,
|
|
@@ -499,7 +488,7 @@ const _TechdocsGenerator = class _TechdocsGenerator {
|
|
|
499
488
|
if (this.options.legacyCopyReadmeMdToIndexMd) {
|
|
500
489
|
await patchIndexPreBuild({ inputDir, logger: childLogger, docsDir });
|
|
501
490
|
}
|
|
502
|
-
const defaultPlugins =
|
|
491
|
+
const defaultPlugins = this.options.defaultPlugins ?? [];
|
|
503
492
|
if (!this.options.omitTechdocsCoreMkdocsPlugin && !defaultPlugins.includes("techdocs-core")) {
|
|
504
493
|
defaultPlugins.push("techdocs-core");
|
|
505
494
|
}
|
|
@@ -530,7 +519,7 @@ const _TechdocsGenerator = class _TechdocsGenerator {
|
|
|
530
519
|
);
|
|
531
520
|
}
|
|
532
521
|
await this.containerRunner.runContainer({
|
|
533
|
-
imageName:
|
|
522
|
+
imageName: this.options.dockerImage ?? TechdocsGenerator.defaultDockerImage,
|
|
534
523
|
args: ["build", "-d", "/output"],
|
|
535
524
|
logStream,
|
|
536
525
|
mountDirs,
|
|
@@ -570,15 +559,8 @@ const _TechdocsGenerator = class _TechdocsGenerator {
|
|
|
570
559
|
);
|
|
571
560
|
}
|
|
572
561
|
}
|
|
573
|
-
}
|
|
574
|
-
/**
|
|
575
|
-
* The default docker image (and version) used to generate content. Public
|
|
576
|
-
* and static so that techdocs-node consumers can use the same version.
|
|
577
|
-
*/
|
|
578
|
-
__publicField$a(_TechdocsGenerator, "defaultDockerImage", "spotify/techdocs:v1.2.3");
|
|
579
|
-
let TechdocsGenerator = _TechdocsGenerator;
|
|
562
|
+
}
|
|
580
563
|
function readGeneratorConfig(config, logger) {
|
|
581
|
-
var _a;
|
|
582
564
|
const legacyGeneratorType = config.getOptionalString(
|
|
583
565
|
"techdocs.generators.techdocs"
|
|
584
566
|
);
|
|
@@ -588,7 +570,7 @@ function readGeneratorConfig(config, logger) {
|
|
|
588
570
|
);
|
|
589
571
|
}
|
|
590
572
|
return {
|
|
591
|
-
runIn:
|
|
573
|
+
runIn: legacyGeneratorType ?? config.getOptionalString("techdocs.generator.runIn") ?? "docker",
|
|
592
574
|
dockerImage: config.getOptionalString("techdocs.generator.dockerImage"),
|
|
593
575
|
pullImage: config.getOptionalBoolean("techdocs.generator.pullImage"),
|
|
594
576
|
omitTechdocsCoreMkdocsPlugin: config.getOptionalBoolean(
|
|
@@ -603,25 +585,16 @@ function readGeneratorConfig(config, logger) {
|
|
|
603
585
|
};
|
|
604
586
|
}
|
|
605
587
|
|
|
606
|
-
var __defProp$9 = Object.defineProperty;
|
|
607
|
-
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
608
|
-
var __publicField$9 = (obj, key, value) => {
|
|
609
|
-
__defNormalProp$9(obj, key + "" , value);
|
|
610
|
-
return value;
|
|
611
|
-
};
|
|
612
588
|
class Generators {
|
|
613
|
-
|
|
614
|
-
__publicField$9(this, "generatorMap", /* @__PURE__ */ new Map());
|
|
615
|
-
}
|
|
589
|
+
generatorMap = /* @__PURE__ */ new Map();
|
|
616
590
|
/**
|
|
617
591
|
* Returns a generators instance containing a generator for TechDocs
|
|
618
592
|
* @param config - A Backstage configuration
|
|
619
593
|
* @param options - Options to configure the TechDocs generator
|
|
620
594
|
*/
|
|
621
595
|
static async fromConfig(config, options) {
|
|
622
|
-
var _a;
|
|
623
596
|
const generators = new Generators();
|
|
624
|
-
const techdocsGenerator =
|
|
597
|
+
const techdocsGenerator = options.customGenerator ?? TechdocsGenerator.fromConfig(config, options);
|
|
625
598
|
generators.register("techdocs", techdocsGenerator);
|
|
626
599
|
return generators;
|
|
627
600
|
}
|
|
@@ -650,8 +623,7 @@ class Generators {
|
|
|
650
623
|
const getMkDocsYml = getMkdocsYml;
|
|
651
624
|
|
|
652
625
|
const parseReferenceAnnotation = (annotationName, entity) => {
|
|
653
|
-
|
|
654
|
-
const annotation = (_a = entity.metadata.annotations) == null ? void 0 : _a[annotationName];
|
|
626
|
+
const annotation = entity.metadata.annotations?.[annotationName];
|
|
655
627
|
if (!annotation) {
|
|
656
628
|
throw new errors.InputError(
|
|
657
629
|
`No location annotation provided in entity: ${entity.metadata.name}`
|
|
@@ -677,7 +649,7 @@ const transformDirLocation = (entity, dirAnnotation, scmIntegrations) => {
|
|
|
677
649
|
};
|
|
678
650
|
}
|
|
679
651
|
case "file": {
|
|
680
|
-
const target =
|
|
652
|
+
const target = backendPluginApi.resolveSafeChildPath(
|
|
681
653
|
path__default.default.dirname(location.target),
|
|
682
654
|
dirAnnotation.target
|
|
683
655
|
);
|
|
@@ -705,34 +677,23 @@ const getLocationForEntity = (entity, scmIntegration) => {
|
|
|
705
677
|
}
|
|
706
678
|
};
|
|
707
679
|
const getDocFilesFromRepository = async (reader, entity, opts) => {
|
|
708
|
-
var _a, _b;
|
|
709
680
|
const { target } = parseReferenceAnnotation(
|
|
710
681
|
"backstage.io/techdocs-ref",
|
|
711
682
|
entity
|
|
712
683
|
);
|
|
713
|
-
|
|
714
|
-
const readTreeResponse = await reader.readTree(target, { etag: opts
|
|
684
|
+
opts?.logger?.debug(`Reading files from ${target}`);
|
|
685
|
+
const readTreeResponse = await reader.readTree(target, { etag: opts?.etag });
|
|
715
686
|
const preparedDir = await readTreeResponse.dir();
|
|
716
|
-
|
|
687
|
+
opts?.logger?.debug(`Tree downloaded and stored at ${preparedDir}`);
|
|
717
688
|
return {
|
|
718
689
|
preparedDir,
|
|
719
690
|
etag: readTreeResponse.etag
|
|
720
691
|
};
|
|
721
692
|
};
|
|
722
693
|
|
|
723
|
-
var __defProp$8 = Object.defineProperty;
|
|
724
|
-
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
725
|
-
var __publicField$8 = (obj, key, value) => {
|
|
726
|
-
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
727
|
-
return value;
|
|
728
|
-
};
|
|
729
694
|
class DirectoryPreparer {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
__publicField$8(this, "reader");
|
|
733
|
-
this.reader = reader;
|
|
734
|
-
this.scmIntegrations = integration.ScmIntegrations.fromConfig(config);
|
|
735
|
-
}
|
|
695
|
+
scmIntegrations;
|
|
696
|
+
reader;
|
|
736
697
|
/**
|
|
737
698
|
* Returns a directory preparer instance
|
|
738
699
|
* @param config - A backstage config
|
|
@@ -741,13 +702,16 @@ class DirectoryPreparer {
|
|
|
741
702
|
static fromConfig(config, options) {
|
|
742
703
|
return new DirectoryPreparer(config, options.logger, options.reader);
|
|
743
704
|
}
|
|
705
|
+
constructor(config, _logger, reader) {
|
|
706
|
+
this.reader = reader;
|
|
707
|
+
this.scmIntegrations = integration.ScmIntegrations.fromConfig(config);
|
|
708
|
+
}
|
|
744
709
|
/** {@inheritDoc PreparerBase.shouldCleanPreparedDirectory} */
|
|
745
710
|
shouldCleanPreparedDirectory() {
|
|
746
711
|
return false;
|
|
747
712
|
}
|
|
748
713
|
/** {@inheritDoc PreparerBase.prepare} */
|
|
749
714
|
async prepare(entity, options) {
|
|
750
|
-
var _a, _b;
|
|
751
715
|
const annotation = parseReferenceAnnotation(
|
|
752
716
|
"backstage.io/techdocs-ref",
|
|
753
717
|
entity
|
|
@@ -759,12 +723,12 @@ class DirectoryPreparer {
|
|
|
759
723
|
);
|
|
760
724
|
switch (type) {
|
|
761
725
|
case "url": {
|
|
762
|
-
|
|
726
|
+
options?.logger?.debug(`Reading files from ${target}`);
|
|
763
727
|
const response = await this.reader.readTree(target, {
|
|
764
|
-
etag: options
|
|
728
|
+
etag: options?.etag
|
|
765
729
|
});
|
|
766
730
|
const preparedDir = await response.dir();
|
|
767
|
-
|
|
731
|
+
options?.logger?.debug(`Tree downloaded and stored at ${preparedDir}`);
|
|
768
732
|
return {
|
|
769
733
|
preparedDir,
|
|
770
734
|
etag: response.etag
|
|
@@ -784,19 +748,9 @@ class DirectoryPreparer {
|
|
|
784
748
|
}
|
|
785
749
|
}
|
|
786
750
|
|
|
787
|
-
var __defProp$7 = Object.defineProperty;
|
|
788
|
-
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
789
|
-
var __publicField$7 = (obj, key, value) => {
|
|
790
|
-
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
791
|
-
return value;
|
|
792
|
-
};
|
|
793
751
|
class UrlPreparer {
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
__publicField$7(this, "reader");
|
|
797
|
-
this.logger = logger;
|
|
798
|
-
this.reader = reader;
|
|
799
|
-
}
|
|
752
|
+
logger;
|
|
753
|
+
reader;
|
|
800
754
|
/**
|
|
801
755
|
* Returns a directory preparer instance
|
|
802
756
|
* @param config - A URL preparer config containing the a logger and reader
|
|
@@ -804,6 +758,10 @@ class UrlPreparer {
|
|
|
804
758
|
static fromConfig(options) {
|
|
805
759
|
return new UrlPreparer(options.reader, options.logger);
|
|
806
760
|
}
|
|
761
|
+
constructor(reader, logger) {
|
|
762
|
+
this.logger = logger;
|
|
763
|
+
this.reader = reader;
|
|
764
|
+
}
|
|
807
765
|
/** {@inheritDoc PreparerBase.shouldCleanPreparedDirectory} */
|
|
808
766
|
shouldCleanPreparedDirectory() {
|
|
809
767
|
return true;
|
|
@@ -812,13 +770,13 @@ class UrlPreparer {
|
|
|
812
770
|
async prepare(entity, options) {
|
|
813
771
|
try {
|
|
814
772
|
return await getDocFilesFromRepository(this.reader, entity, {
|
|
815
|
-
etag: options
|
|
773
|
+
etag: options?.etag,
|
|
816
774
|
logger: this.logger
|
|
817
775
|
});
|
|
818
776
|
} catch (error) {
|
|
819
777
|
errors.assertError(error);
|
|
820
778
|
if (error.name === "NotModifiedError") {
|
|
821
|
-
this.logger.debug(`Cache is valid for etag ${options
|
|
779
|
+
this.logger.debug(`Cache is valid for etag ${options?.etag}`);
|
|
822
780
|
} else {
|
|
823
781
|
this.logger.debug(
|
|
824
782
|
`Unable to fetch files for building docs ${error.message}`
|
|
@@ -829,16 +787,8 @@ class UrlPreparer {
|
|
|
829
787
|
}
|
|
830
788
|
}
|
|
831
789
|
|
|
832
|
-
var __defProp$6 = Object.defineProperty;
|
|
833
|
-
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
834
|
-
var __publicField$6 = (obj, key, value) => {
|
|
835
|
-
__defNormalProp$6(obj, key + "" , value);
|
|
836
|
-
return value;
|
|
837
|
-
};
|
|
838
790
|
class Preparers {
|
|
839
|
-
|
|
840
|
-
__publicField$6(this, "preparerMap", /* @__PURE__ */ new Map());
|
|
841
|
-
}
|
|
791
|
+
preparerMap = /* @__PURE__ */ new Map();
|
|
842
792
|
/**
|
|
843
793
|
* Returns a generators instance containing a generator for TechDocs
|
|
844
794
|
* @public
|
|
@@ -885,12 +835,6 @@ class Preparers {
|
|
|
885
835
|
}
|
|
886
836
|
}
|
|
887
837
|
|
|
888
|
-
var __defProp$5 = Object.defineProperty;
|
|
889
|
-
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
890
|
-
var __publicField$5 = (obj, key, value) => {
|
|
891
|
-
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
892
|
-
return value;
|
|
893
|
-
};
|
|
894
838
|
const streamToBuffer$1 = (stream) => {
|
|
895
839
|
return new Promise((resolve, reject) => {
|
|
896
840
|
try {
|
|
@@ -907,13 +851,13 @@ const streamToBuffer$1 = (stream) => {
|
|
|
907
851
|
});
|
|
908
852
|
};
|
|
909
853
|
class AwsS3Publish {
|
|
854
|
+
storageClient;
|
|
855
|
+
bucketName;
|
|
856
|
+
legacyPathCasing;
|
|
857
|
+
logger;
|
|
858
|
+
bucketRootPath;
|
|
859
|
+
sse;
|
|
910
860
|
constructor(options) {
|
|
911
|
-
__publicField$5(this, "storageClient");
|
|
912
|
-
__publicField$5(this, "bucketName");
|
|
913
|
-
__publicField$5(this, "legacyPathCasing");
|
|
914
|
-
__publicField$5(this, "logger");
|
|
915
|
-
__publicField$5(this, "bucketRootPath");
|
|
916
|
-
__publicField$5(this, "sse");
|
|
917
861
|
this.storageClient = options.storageClient;
|
|
918
862
|
this.bucketName = options.bucketName;
|
|
919
863
|
this.legacyPathCasing = options.legacyPathCasing;
|
|
@@ -1284,19 +1228,13 @@ class AwsS3Publish {
|
|
|
1284
1228
|
}
|
|
1285
1229
|
}
|
|
1286
1230
|
|
|
1287
|
-
var __defProp$4 = Object.defineProperty;
|
|
1288
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1289
|
-
var __publicField$4 = (obj, key, value) => {
|
|
1290
|
-
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1291
|
-
return value;
|
|
1292
|
-
};
|
|
1293
1231
|
const BATCH_CONCURRENCY = 3;
|
|
1294
1232
|
class AzureBlobStoragePublish {
|
|
1233
|
+
storageClient;
|
|
1234
|
+
containerName;
|
|
1235
|
+
legacyPathCasing;
|
|
1236
|
+
logger;
|
|
1295
1237
|
constructor(options) {
|
|
1296
|
-
__publicField$4(this, "storageClient");
|
|
1297
|
-
__publicField$4(this, "containerName");
|
|
1298
|
-
__publicField$4(this, "legacyPathCasing");
|
|
1299
|
-
__publicField$4(this, "logger");
|
|
1300
1238
|
this.storageClient = options.storageClient;
|
|
1301
1239
|
this.containerName = options.containerName;
|
|
1302
1240
|
this.legacyPathCasing = options.legacyPathCasing;
|
|
@@ -1595,13 +1533,12 @@ class AzureBlobStoragePublish {
|
|
|
1595
1533
|
prefix,
|
|
1596
1534
|
maxPageSize
|
|
1597
1535
|
}) {
|
|
1598
|
-
var _a, _b;
|
|
1599
1536
|
const blobs = [];
|
|
1600
1537
|
const container = this.storageClient.getContainerClient(this.containerName);
|
|
1601
1538
|
let iterator = container.listBlobsFlat({ prefix }).byPage({ maxPageSize });
|
|
1602
1539
|
let response = (await iterator.next()).value;
|
|
1603
1540
|
do {
|
|
1604
|
-
for (const blob of
|
|
1541
|
+
for (const blob of response?.segment?.blobItems ?? []) {
|
|
1605
1542
|
blobs.push(blob.name);
|
|
1606
1543
|
}
|
|
1607
1544
|
iterator = container.listBlobsFlat({ prefix }).byPage({ continuationToken: response.continuationToken, maxPageSize });
|
|
@@ -1611,19 +1548,13 @@ class AzureBlobStoragePublish {
|
|
|
1611
1548
|
}
|
|
1612
1549
|
}
|
|
1613
1550
|
|
|
1614
|
-
var __defProp$3 = Object.defineProperty;
|
|
1615
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1616
|
-
var __publicField$3 = (obj, key, value) => {
|
|
1617
|
-
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1618
|
-
return value;
|
|
1619
|
-
};
|
|
1620
1551
|
class MigrateWriteStream extends stream.Writable {
|
|
1552
|
+
logger;
|
|
1553
|
+
removeOriginal;
|
|
1554
|
+
maxConcurrency;
|
|
1555
|
+
inFlight = 0;
|
|
1621
1556
|
constructor(logger, removeOriginal, concurrency) {
|
|
1622
1557
|
super({ objectMode: true });
|
|
1623
|
-
__publicField$3(this, "logger");
|
|
1624
|
-
__publicField$3(this, "removeOriginal");
|
|
1625
|
-
__publicField$3(this, "maxConcurrency");
|
|
1626
|
-
__publicField$3(this, "inFlight", 0);
|
|
1627
1558
|
this.logger = logger;
|
|
1628
1559
|
this.removeOriginal = removeOriginal;
|
|
1629
1560
|
this.maxConcurrency = concurrency;
|
|
@@ -1661,19 +1592,13 @@ class MigrateWriteStream extends stream.Writable {
|
|
|
1661
1592
|
}
|
|
1662
1593
|
}
|
|
1663
1594
|
|
|
1664
|
-
var __defProp$2 = Object.defineProperty;
|
|
1665
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1666
|
-
var __publicField$2 = (obj, key, value) => {
|
|
1667
|
-
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1668
|
-
return value;
|
|
1669
|
-
};
|
|
1670
1595
|
class GoogleGCSPublish {
|
|
1596
|
+
storageClient;
|
|
1597
|
+
bucketName;
|
|
1598
|
+
legacyPathCasing;
|
|
1599
|
+
logger;
|
|
1600
|
+
bucketRootPath;
|
|
1671
1601
|
constructor(options) {
|
|
1672
|
-
__publicField$2(this, "storageClient");
|
|
1673
|
-
__publicField$2(this, "bucketName");
|
|
1674
|
-
__publicField$2(this, "legacyPathCasing");
|
|
1675
|
-
__publicField$2(this, "logger");
|
|
1676
|
-
__publicField$2(this, "bucketRootPath");
|
|
1677
1602
|
this.storageClient = options.storageClient;
|
|
1678
1603
|
this.bucketName = options.bucketName;
|
|
1679
1604
|
this.legacyPathCasing = options.legacyPathCasing;
|
|
@@ -1920,18 +1845,12 @@ class GoogleGCSPublish {
|
|
|
1920
1845
|
}
|
|
1921
1846
|
}
|
|
1922
1847
|
|
|
1923
|
-
var __defProp$1 = Object.defineProperty;
|
|
1924
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1925
|
-
var __publicField$1 = (obj, key, value) => {
|
|
1926
|
-
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1927
|
-
return value;
|
|
1928
|
-
};
|
|
1929
1848
|
class LocalPublish {
|
|
1849
|
+
legacyPathCasing;
|
|
1850
|
+
logger;
|
|
1851
|
+
discovery;
|
|
1852
|
+
staticDocsDir;
|
|
1930
1853
|
constructor(options) {
|
|
1931
|
-
__publicField$1(this, "legacyPathCasing");
|
|
1932
|
-
__publicField$1(this, "logger");
|
|
1933
|
-
__publicField$1(this, "discovery");
|
|
1934
|
-
__publicField$1(this, "staticDocsDir");
|
|
1935
1854
|
this.logger = options.logger;
|
|
1936
1855
|
this.discovery = options.discovery;
|
|
1937
1856
|
this.legacyPathCasing = options.legacyPathCasing;
|
|
@@ -1946,7 +1865,7 @@ class LocalPublish {
|
|
|
1946
1865
|
);
|
|
1947
1866
|
if (!staticDocsDir) {
|
|
1948
1867
|
try {
|
|
1949
|
-
staticDocsDir =
|
|
1868
|
+
staticDocsDir = backendPluginApi.resolvePackagePath(
|
|
1950
1869
|
"@backstage/plugin-techdocs-backend",
|
|
1951
1870
|
"static/docs"
|
|
1952
1871
|
);
|
|
@@ -1970,8 +1889,7 @@ class LocalPublish {
|
|
|
1970
1889
|
entity,
|
|
1971
1890
|
directory
|
|
1972
1891
|
}) {
|
|
1973
|
-
|
|
1974
|
-
const entityNamespace = (_a = entity.metadata.namespace) != null ? _a : "default";
|
|
1892
|
+
const entityNamespace = entity.metadata.namespace ?? "default";
|
|
1975
1893
|
let publishDir;
|
|
1976
1894
|
try {
|
|
1977
1895
|
publishDir = this.staticEntityPathJoin(
|
|
@@ -2076,8 +1994,7 @@ class LocalPublish {
|
|
|
2076
1994
|
return router;
|
|
2077
1995
|
}
|
|
2078
1996
|
async hasDocsBeenGenerated(entity) {
|
|
2079
|
-
|
|
2080
|
-
const namespace = (_a = entity.metadata.namespace) != null ? _a : "default";
|
|
1997
|
+
const namespace = entity.metadata.namespace ?? "default";
|
|
2081
1998
|
try {
|
|
2082
1999
|
const indexHtmlPath = this.staticEntityPathJoin(
|
|
2083
2000
|
namespace,
|
|
@@ -2142,24 +2059,18 @@ class LocalPublish {
|
|
|
2142
2059
|
let staticEntityPath = this.staticDocsDir;
|
|
2143
2060
|
allParts.map((part) => part.split(path__default.default.sep)).flat().forEach((part, index) => {
|
|
2144
2061
|
if (index < 3) {
|
|
2145
|
-
staticEntityPath =
|
|
2062
|
+
staticEntityPath = backendPluginApi.resolveSafeChildPath(
|
|
2146
2063
|
staticEntityPath,
|
|
2147
2064
|
this.legacyPathCasing ? part : part.toLowerCase()
|
|
2148
2065
|
);
|
|
2149
2066
|
return;
|
|
2150
2067
|
}
|
|
2151
|
-
staticEntityPath =
|
|
2068
|
+
staticEntityPath = backendPluginApi.resolveSafeChildPath(staticEntityPath, part);
|
|
2152
2069
|
});
|
|
2153
2070
|
return staticEntityPath;
|
|
2154
2071
|
}
|
|
2155
2072
|
}
|
|
2156
2073
|
|
|
2157
|
-
var __defProp = Object.defineProperty;
|
|
2158
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2159
|
-
var __publicField = (obj, key, value) => {
|
|
2160
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2161
|
-
return value;
|
|
2162
|
-
};
|
|
2163
2074
|
const streamToBuffer = (stream) => {
|
|
2164
2075
|
return new Promise((resolve, reject) => {
|
|
2165
2076
|
try {
|
|
@@ -2179,10 +2090,10 @@ const bufferToStream = (buffer) => {
|
|
|
2179
2090
|
return stream$1;
|
|
2180
2091
|
};
|
|
2181
2092
|
class OpenStackSwiftPublish {
|
|
2093
|
+
storageClient;
|
|
2094
|
+
containerName;
|
|
2095
|
+
logger;
|
|
2182
2096
|
constructor(options) {
|
|
2183
|
-
__publicField(this, "storageClient");
|
|
2184
|
-
__publicField(this, "containerName");
|
|
2185
|
-
__publicField(this, "logger");
|
|
2186
2097
|
this.storageClient = options.storageClient;
|
|
2187
2098
|
this.containerName = options.containerName;
|
|
2188
2099
|
this.logger = options.logger;
|
|
@@ -2432,11 +2343,10 @@ class Publisher {
|
|
|
2432
2343
|
* @param options - Options for configuring the publisher factory
|
|
2433
2344
|
*/
|
|
2434
2345
|
static async fromConfig(config, options) {
|
|
2435
|
-
var _a;
|
|
2436
2346
|
const { logger, discovery } = options;
|
|
2437
|
-
const publisherType =
|
|
2347
|
+
const publisherType = config.getOptionalString(
|
|
2438
2348
|
"techdocs.publisher.type"
|
|
2439
|
-
)
|
|
2349
|
+
) ?? "local";
|
|
2440
2350
|
switch (publisherType) {
|
|
2441
2351
|
case "googleGcs":
|
|
2442
2352
|
logger.info("Creating Google Storage Bucket publisher for TechDocs");
|