@techdocs/cli 1.13.0 → 1.14.0-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 +15 -0
- package/dist/commands/generate/generate.cjs.js +9 -3
- package/dist/commands/generate/generate.cjs.js.map +1 -1
- package/dist/commands/index.cjs.js +17 -25
- package/dist/commands/index.cjs.js.map +1 -1
- package/dist/commands/serve/mkdocs.cjs.js +18 -7
- package/dist/commands/serve/mkdocs.cjs.js.map +1 -1
- package/dist/commands/serve/serve.cjs.js +26 -20
- package/dist/commands/serve/serve.cjs.js.map +1 -1
- package/dist/commands/serve/utils.cjs.js +11 -0
- package/dist/commands/serve/utils.cjs.js.map +1 -1
- package/dist/embedded-app/.config-schema.json +160 -160
- package/dist/embedded-app/index.html +1 -1
- package/dist/embedded-app/index.html.tmpl +1 -1
- package/dist/embedded-app/static/123.62e39427e387.chunk.js +2 -0
- package/dist/embedded-app/static/123.62e39427e387.chunk.js.map +1 -0
- package/dist/embedded-app/static/1659.834cbdaa7cf5.chunk.js +2 -0
- package/dist/embedded-app/static/1659.834cbdaa7cf5.chunk.js.map +1 -0
- package/dist/embedded-app/static/4587.9743bb6b94a7.chunk.js +2 -0
- package/dist/embedded-app/static/4587.9743bb6b94a7.chunk.js.map +1 -0
- package/dist/embedded-app/static/{4609.afdaf67e3d37.chunk.js → 4609.cac0ebf6bb92.chunk.js} +2 -2
- package/dist/embedded-app/static/{4609.afdaf67e3d37.chunk.js.map → 4609.cac0ebf6bb92.chunk.js.map} +1 -1
- package/dist/embedded-app/static/{5124.bf809bc06c78.chunk.js → 5124.7da4bbeaafd0.chunk.js} +2 -2
- package/dist/embedded-app/static/{5124.bf809bc06c78.chunk.js.map → 5124.7da4bbeaafd0.chunk.js.map} +1 -1
- package/dist/embedded-app/static/5877.dcbb54defb88.chunk.js +2 -0
- package/dist/embedded-app/static/5877.dcbb54defb88.chunk.js.map +1 -0
- package/dist/embedded-app/static/main.7dc68125121e.js.map +1 -1
- package/dist/embedded-app/static/{runtime.fa776ba09ef1.js → runtime.1a8d862d04e5.js} +2 -2
- package/dist/embedded-app/static/{runtime.fa776ba09ef1.js.map → runtime.1a8d862d04e5.js.map} +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/lib/{engineConfig.cjs.js → engines/mkdocs.cjs.js} +5 -24
- package/dist/lib/engines/mkdocs.cjs.js.map +1 -0
- package/dist/lib/engines/registry.cjs.js +29 -0
- package/dist/lib/engines/registry.cjs.js.map +1 -0
- package/dist/lib/engines/zensical.cjs.js +119 -0
- package/dist/lib/engines/zensical.cjs.js.map +1 -0
- package/dist/lib/httpServer.cjs.js +4 -2
- package/dist/lib/httpServer.cjs.js.map +1 -1
- package/dist/lib/livereload.cjs.js +9 -6
- package/dist/lib/livereload.cjs.js.map +1 -1
- package/dist/lib/prepareServeConfig.cjs.js +17 -0
- package/dist/lib/prepareServeConfig.cjs.js.map +1 -0
- package/dist/lib/server.cjs.js +2 -1
- package/dist/lib/server.cjs.js.map +1 -1
- package/dist/{package.json.cjs.js → packages/techdocs-cli/package.json.cjs.js} +1 -1
- package/dist/plugins/techdocs-zensical-internal/src/TechdocsZensicalGenerator.cjs.js +178 -0
- package/dist/plugins/techdocs-zensical-internal/src/TechdocsZensicalGenerator.cjs.js.map +1 -0
- package/dist/plugins/techdocs-zensical-internal/src/zensicalHelpers.cjs.js +185 -0
- package/dist/plugins/techdocs-zensical-internal/src/zensicalHelpers.cjs.js.map +1 -0
- package/package.json +13 -8
- package/dist/embedded-app/static/123.b7794a0eee64.chunk.js +0 -2
- package/dist/embedded-app/static/123.b7794a0eee64.chunk.js.map +0 -1
- package/dist/embedded-app/static/1659.b8b0e908d038.chunk.js +0 -2
- package/dist/embedded-app/static/1659.b8b0e908d038.chunk.js.map +0 -1
- package/dist/embedded-app/static/4587.fa2bf602f965.chunk.js +0 -2
- package/dist/embedded-app/static/4587.fa2bf602f965.chunk.js.map +0 -1
- package/dist/embedded-app/static/5877.a2e28865fc9e.chunk.js +0 -2
- package/dist/embedded-app/static/5877.a2e28865fc9e.chunk.js.map +0 -1
- package/dist/lib/engineConfig.cjs.js.map +0 -1
- /package/dist/{package.json.cjs.js.map → packages/techdocs-cli/package.json.cjs.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @techdocs/cli
|
|
2
2
|
|
|
3
|
+
## 1.14.0-next.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a4604d2: Add Zensical support to `serve`, `serve:raw` and `generate` via `--engine zensical` (or the `backstage.io/techdocs-engine` annotation in `catalog-info.yaml`), including live reload in the preview app. The default `--docker-image` is now chosen per engine instead of always being `spotify/techdocs`, and matches the image the TechDocs backend uses for that engine, so MkDocs previews now use `spotify/techdocs:v1.2.8` instead of `latest`. Passing `--docker-image` explicitly behaves as before.
|
|
8
|
+
|
|
9
|
+
The `serve` flags `--mkdocs-port`, `--mkdocs-config-file-name` and `--mkdocs-parameter-*` are deprecated in favor of `--engine-port`, `--config-file-name` and `--parameter-*`. If both the old and new flag are given, the new one wins and the warning says the old one is ignored.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @backstage/backend-defaults@0.18.2-next.0
|
|
15
|
+
- @backstage/plugin-techdocs-node@2.2.0-next.0
|
|
16
|
+
- @backstage/backend-plugin-api@1.11.1-next.0
|
|
17
|
+
|
|
3
18
|
## 1.13.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
|
@@ -9,7 +9,7 @@ var pluginTechdocsNode = require('@backstage/plugin-techdocs-node');
|
|
|
9
9
|
var config = require('@backstage/config');
|
|
10
10
|
var utility = require('../../lib/utility.cjs.js');
|
|
11
11
|
var etag = require('../../lib/etag.cjs.js');
|
|
12
|
-
var
|
|
12
|
+
var registry = require('../../lib/engines/registry.cjs.js');
|
|
13
13
|
var catalogEntity = require('../../lib/catalogEntity.cjs.js');
|
|
14
14
|
|
|
15
15
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
@@ -35,8 +35,8 @@ async function generate(opts) {
|
|
|
35
35
|
source: engineSource,
|
|
36
36
|
entity: catalogEntity$1
|
|
37
37
|
} = await catalogEntity.resolveEngine(sourceDir, opts.engine, logger);
|
|
38
|
-
const engineConfig
|
|
39
|
-
logger.info(`Using engine: ${engine} (binary: ${engineConfig
|
|
38
|
+
const engineConfig = registry.getEngineConfig(engine, engineSource);
|
|
39
|
+
logger.info(`Using engine: ${engine} (binary: ${engineConfig.binary})`);
|
|
40
40
|
const outputDir = path.resolve(opts.outputDir);
|
|
41
41
|
const omitTechdocsCorePlugin = opts.omitTechdocsCoreMkdocsPlugin;
|
|
42
42
|
const dockerImage = opts.dockerImage;
|
|
@@ -84,6 +84,12 @@ async function generate(opts) {
|
|
|
84
84
|
const generators = await pluginTechdocsNode.Generators.fromConfig(config$1, {
|
|
85
85
|
logger
|
|
86
86
|
});
|
|
87
|
+
if (engineConfig.createGenerator) {
|
|
88
|
+
generators.register(
|
|
89
|
+
engine,
|
|
90
|
+
engineConfig.createGenerator(config$1, { logger })
|
|
91
|
+
);
|
|
92
|
+
}
|
|
87
93
|
const baseEntity = catalogEntity$1 ?? {
|
|
88
94
|
apiVersion: "backstage.io/v1alpha1",
|
|
89
95
|
kind: "Component",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.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 { join, resolve } from 'node:path';\nimport { OptionValues } from 'commander';\nimport fs from 'fs-extra';\nimport JSON5 from 'json5';\nimport {\n Generators,\n ParsedLocationAnnotation,\n getMkdocsYml,\n TECHDOCS_ENGINE_CATALOG_ANNOTATION_KEY,\n} from '@backstage/plugin-techdocs-node';\nimport { ConfigReader } from '@backstage/config';\nimport { Entity } from '@backstage/catalog-model';\nimport {\n convertTechDocsRefToLocationAnnotation,\n createLogger,\n getLogStream,\n} from '../../lib/utility';\nimport { computeDirectoryEtag } from '../../lib/etag';\nimport { getEngineConfig } from '../../lib/engineConfig';\nimport { resolveEngine } from '../../lib/catalogEntity';\n\nconst TECHDOCS_METADATA_FILE = 'techdocs_metadata.json';\nconst GENERATED_SITE_ETAG_EXCLUDED_FILES = [\n TECHDOCS_METADATA_FILE,\n // The compressed sitemap can include gzip metadata that changes between\n // otherwise identical generated sites; sitemap.xml still captures content.\n 'sitemap.xml.gz',\n // mkdocs writes build-date lastmod entries into sitemap.xml, so the hash\n // changes daily even when the documentation content is identical.\n 'sitemap.xml',\n];\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 const sourceDir = resolve(opts.sourceDir);\n\n const {\n engine,\n source: engineSource,\n entity: catalogEntity,\n } = await resolveEngine(sourceDir, opts.engine, logger);\n\n const engineConfig = getEngineConfig(engine, engineSource);\n logger.info(`Using engine: ${engine} (binary: ${engineConfig.binary})`);\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 const disableExternalFonts = opts.disableExternalFonts;\n const defaultPlugins = opts.defaultPlugin;\n const dangerouslyAllowAdditionalKeys = opts.dangerouslyAllowAdditionalKeys;\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 defaultEngine: engine,\n mkdocs: {\n legacyCopyReadmeMdToIndexMd,\n omitTechdocsCorePlugin,\n disableExternalFonts,\n defaultPlugins,\n dangerouslyAllowAdditionalKeys,\n },\n },\n },\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 const hasExplicitEtag = opts.etag !== undefined;\n const etag = hasExplicitEtag ? opts.etag : undefined;\n\n // Generate docs using @backstage/plugin-techdocs-node\n const generators = await Generators.fromConfig(config, {\n logger,\n });\n\n // Stamp the resolved engine onto the entity so that an explicit --engine\n // flag takes precedence over the catalog annotation in generators.get().\n const baseEntity: Entity = catalogEntity ?? {\n apiVersion: 'backstage.io/v1alpha1',\n kind: 'Component',\n metadata: { name: 'local' },\n };\n const entity: Entity = {\n ...baseEntity,\n metadata: {\n ...baseEntity.metadata,\n annotations: {\n ...baseEntity.metadata.annotations,\n [TECHDOCS_ENGINE_CATALOG_ANNOTATION_KEY]: engine,\n },\n },\n };\n const generator = generators.get(entity);\n\n logger.info('Generating documentation...');\n\n await generator.run({\n inputDir: sourceDir,\n outputDir,\n ...(opts.techdocsRef\n ? {\n parsedLocationAnnotation,\n }\n : {}),\n logger,\n etag,\n logStream: getLogStream(logger),\n siteOptions: { name: opts.siteName },\n runAsDefaultUser: opts.runAsDefaultUser,\n });\n\n if (!hasExplicitEtag) {\n const generatedSiteEtag = await computeDirectoryEtag(outputDir, {\n exclude: GENERATED_SITE_ETAG_EXCLUDED_FILES,\n });\n const metadataPath = join(outputDir, TECHDOCS_METADATA_FILE);\n const metadata = JSON5.parse(await fs.readFile(metadataPath, 'utf8'));\n await fs.writeJson(\n metadataPath,\n { ...metadata, etag: generatedSiteEtag },\n { spaces: 2 },\n );\n logger.info(`Computed generated site content hash: ${generatedSiteEtag}`);\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","catalogEntity","resolveEngine","engineConfig","getEngineConfig","fs","getMkdocsYml","config","ConfigReader","convertTechDocsRefToLocationAnnotation","etag","Generators","TECHDOCS_ENGINE_CATALOG_ANNOTATION_KEY","getLogStream","computeDirectoryEtag","join","JSON5"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,MAAM,sBAAA,GAAyB,wBAAA;AAC/B,MAAM,kCAAA,GAAqC;AAAA,EACzC,sBAAA;AAAA;AAAA;AAAA,EAGA,gBAAA;AAAA;AAAA;AAAA,EAGA;AACF,CAAA;AAEA,eAA8B,SAAS,IAAA,EAAoB;AAKzD,EAAA,MAAM,SAASA,oBAAA,CAAa,EAAE,OAAA,EAAS,IAAA,CAAK,SAAS,CAAA;AACrD,EAAA,MAAM,SAAA,GAAYC,YAAA,CAAQ,IAAA,CAAK,SAAS,CAAA;AAExC,EAAA,MAAM;AAAA,IACJ,MAAA;AAAA,IACA,MAAA,EAAQ,YAAA;AAAA,IACR,MAAA,EAAQC;AAAA,MACN,MAAMC,2BAAA,CAAc,SAAA,EAAW,IAAA,CAAK,QAAQ,MAAM,CAAA;AAEtD,EAAA,MAAMC,cAAA,GAAeC,4BAAA,CAAgB,MAAA,EAAQ,YAAY,CAAA;AACzD,EAAA,MAAA,CAAO,KAAK,CAAA,cAAA,EAAiB,MAAM,CAA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AAAA,IACnC,kBAAkB,IAAA,CAAK;AAAA,GACxB,CAAA;AAED,EAAA,IAAI,CAAC,eAAA,EAAiB;AACpB,IAAA,MAAM,iBAAA,GAAoB,MAAMC,yBAAA,CAAqB,SAAA,EAAW;AAAA,MAC9D,OAAA,EAAS;AAAA,KACV,CAAA;AACD,IAAA,MAAM,YAAA,GAAeC,SAAA,CAAK,SAAA,EAAW,sBAAsB,CAAA;AAC3D,IAAA,MAAM,QAAA,GAAWC,uBAAM,KAAA,CAAM,MAAMX,oBAAG,QAAA,CAAS,YAAA,EAAc,MAAM,CAAC,CAAA;AACpE,IAAA,MAAMA,mBAAA,CAAG,SAAA;AAAA,MACP,YAAA;AAAA,MACA,EAAE,GAAG,QAAA,EAAU,IAAA,EAAM,iBAAA,EAAkB;AAAA,MACvC,EAAE,QAAQ,CAAA;AAAE,KACd;AACA,IAAA,MAAA,CAAO,IAAA,CAAK,CAAA,sCAAA,EAAyC,iBAAiB,CAAA,CAAE,CAAA;AAAA,EAC1E;AAEA,EAAA,IAAI,iBAAA,EAAmB;AACrB,IAAA,OAAA,CAAQ,EAAA,CAAG,QAAQ,YAAY;AAC7B,MAAAA,mBAAA,CAAG,MAAA,CAAO,aAAA,EAAe,EAAE,CAAA;AAAA,IAC7B,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,MAAA,CAAO,KAAK,OAAO,CAAA;AACrB;;"}
|
|
1
|
+
{"version":3,"file":"generate.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 { join, resolve } from 'node:path';\nimport { OptionValues } from 'commander';\nimport fs from 'fs-extra';\nimport JSON5 from 'json5';\nimport {\n Generators,\n ParsedLocationAnnotation,\n getMkdocsYml,\n TECHDOCS_ENGINE_CATALOG_ANNOTATION_KEY,\n} from '@backstage/plugin-techdocs-node';\nimport { ConfigReader } from '@backstage/config';\nimport { Entity } from '@backstage/catalog-model';\nimport {\n convertTechDocsRefToLocationAnnotation,\n createLogger,\n getLogStream,\n} from '../../lib/utility';\nimport { computeDirectoryEtag } from '../../lib/etag';\nimport { getEngineConfig } from '../../lib/engines';\nimport { resolveEngine } from '../../lib/catalogEntity';\n\nconst TECHDOCS_METADATA_FILE = 'techdocs_metadata.json';\nconst GENERATED_SITE_ETAG_EXCLUDED_FILES = [\n TECHDOCS_METADATA_FILE,\n // The compressed sitemap can include gzip metadata that changes between\n // otherwise identical generated sites; sitemap.xml still captures content.\n 'sitemap.xml.gz',\n // mkdocs writes build-date lastmod entries into sitemap.xml, so the hash\n // changes daily even when the documentation content is identical.\n 'sitemap.xml',\n];\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 const sourceDir = resolve(opts.sourceDir);\n\n const {\n engine,\n source: engineSource,\n entity: catalogEntity,\n } = await resolveEngine(sourceDir, opts.engine, logger);\n\n const engineConfig = getEngineConfig(engine, engineSource);\n logger.info(`Using engine: ${engine} (binary: ${engineConfig.binary})`);\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 const disableExternalFonts = opts.disableExternalFonts;\n const defaultPlugins = opts.defaultPlugin;\n const dangerouslyAllowAdditionalKeys = opts.dangerouslyAllowAdditionalKeys;\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 defaultEngine: engine,\n mkdocs: {\n legacyCopyReadmeMdToIndexMd,\n omitTechdocsCorePlugin,\n disableExternalFonts,\n defaultPlugins,\n dangerouslyAllowAdditionalKeys,\n },\n },\n },\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 const hasExplicitEtag = opts.etag !== undefined;\n const etag = hasExplicitEtag ? opts.etag : undefined;\n\n // Generate docs using @backstage/plugin-techdocs-node\n const generators = await Generators.fromConfig(config, {\n logger,\n });\n // Engines other than MkDocs ship their own generator; register the one for\n // the detected engine so generators.get() below can resolve it.\n if (engineConfig.createGenerator) {\n generators.register(\n engine,\n engineConfig.createGenerator(config, { logger }),\n );\n }\n\n // Stamp the resolved engine onto the entity so that an explicit --engine\n // flag takes precedence over the catalog annotation in generators.get().\n const baseEntity: Entity = catalogEntity ?? {\n apiVersion: 'backstage.io/v1alpha1',\n kind: 'Component',\n metadata: { name: 'local' },\n };\n const entity: Entity = {\n ...baseEntity,\n metadata: {\n ...baseEntity.metadata,\n annotations: {\n ...baseEntity.metadata.annotations,\n [TECHDOCS_ENGINE_CATALOG_ANNOTATION_KEY]: engine,\n },\n },\n };\n const generator = generators.get(entity);\n\n logger.info('Generating documentation...');\n\n await generator.run({\n inputDir: sourceDir,\n outputDir,\n ...(opts.techdocsRef\n ? {\n parsedLocationAnnotation,\n }\n : {}),\n logger,\n etag,\n logStream: getLogStream(logger),\n siteOptions: { name: opts.siteName },\n runAsDefaultUser: opts.runAsDefaultUser,\n });\n\n if (!hasExplicitEtag) {\n const generatedSiteEtag = await computeDirectoryEtag(outputDir, {\n exclude: GENERATED_SITE_ETAG_EXCLUDED_FILES,\n });\n const metadataPath = join(outputDir, TECHDOCS_METADATA_FILE);\n const metadata = JSON5.parse(await fs.readFile(metadataPath, 'utf8'));\n await fs.writeJson(\n metadataPath,\n { ...metadata, etag: generatedSiteEtag },\n { spaces: 2 },\n );\n logger.info(`Computed generated site content hash: ${generatedSiteEtag}`);\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","catalogEntity","resolveEngine","getEngineConfig","fs","getMkdocsYml","config","ConfigReader","convertTechDocsRefToLocationAnnotation","etag","Generators","TECHDOCS_ENGINE_CATALOG_ANNOTATION_KEY","getLogStream","computeDirectoryEtag","join","JSON5"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,MAAM,sBAAA,GAAyB,wBAAA;AAC/B,MAAM,kCAAA,GAAqC;AAAA,EACzC,sBAAA;AAAA;AAAA;AAAA,EAGA,gBAAA;AAAA;AAAA;AAAA,EAGA;AACF,CAAA;AAEA,eAA8B,SAAS,IAAA,EAAoB;AAKzD,EAAA,MAAM,SAASA,oBAAA,CAAa,EAAE,OAAA,EAAS,IAAA,CAAK,SAAS,CAAA;AACrD,EAAA,MAAM,SAAA,GAAYC,YAAA,CAAQ,IAAA,CAAK,SAAS,CAAA;AAExC,EAAA,MAAM;AAAA,IACJ,MAAA;AAAA,IACA,MAAA,EAAQ,YAAA;AAAA,IACR,MAAA,EAAQC;AAAA,MACN,MAAMC,2BAAA,CAAc,SAAA,EAAW,IAAA,CAAK,QAAQ,MAAM,CAAA;AAEtD,EAAA,MAAM,YAAA,GAAeC,wBAAA,CAAgB,MAAA,EAAQ,YAAY,C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DockerImage = pluginTechdocsNode.TechdocsGenerator.defaultDockerImage;
|
|
6
3
|
const defaultPreviewAppPort = "3000";
|
|
7
4
|
function registerCommands(program) {
|
|
8
|
-
program.command("generate").description(
|
|
5
|
+
program.command("generate").description(
|
|
6
|
+
"Generate a TechDocs documentation site with the selected engine (MkDocs by default)."
|
|
7
|
+
).option(
|
|
9
8
|
"--source-dir <PATH>",
|
|
10
9
|
"Source directory containing mkdocs.yml and docs/ directory.",
|
|
11
10
|
"."
|
|
@@ -15,11 +14,10 @@ function registerCommands(program) {
|
|
|
15
14
|
"./site/"
|
|
16
15
|
).option(
|
|
17
16
|
"--docker-image <DOCKER_IMAGE>",
|
|
18
|
-
"
|
|
19
|
-
defaultDockerImage
|
|
17
|
+
"Docker image to use. Defaults to the selected engine's image."
|
|
20
18
|
).option("--no-pull", "Do not pull the latest docker image").option(
|
|
21
19
|
"--no-docker",
|
|
22
|
-
"Do not use Docker,
|
|
20
|
+
"Do not use Docker, run the engine and its plugins in the current user environment."
|
|
23
21
|
).option(
|
|
24
22
|
"--techdocs-ref <HOST_TYPE:URL>",
|
|
25
23
|
"The repository hosting documentation source files e.g. url:https://ghe.mycompany.net.com/org/repo.\nThis value is same as the backstage.io/techdocs-ref annotation of the corresponding Backstage entity.\nIt is completely fine to skip this as it is only being used to set repo_url in mkdocs.yml if not found.\n"
|
|
@@ -28,7 +26,7 @@ function registerCommands(program) {
|
|
|
28
26
|
"A unique identifier for the prepared tree e.g. commit SHA. If provided it will be stored in techdocs_metadata.json. If omitted, a sha256 content hash of the generated site output is computed automatically."
|
|
29
27
|
).option(
|
|
30
28
|
"--site-name",
|
|
31
|
-
"Name for site when using default
|
|
29
|
+
"Name for site when using the default config",
|
|
32
30
|
"Documentation Site"
|
|
33
31
|
).option("-v, --verbose", "Enable verbose output.", false).option(
|
|
34
32
|
"--omitTechdocsCoreMkdocsPlugin",
|
|
@@ -170,8 +168,7 @@ function registerCommands(program) {
|
|
|
170
168
|
"Serve a documentation project locally using the configured engine."
|
|
171
169
|
).option(
|
|
172
170
|
"-i, --docker-image <DOCKER_IMAGE>",
|
|
173
|
-
"
|
|
174
|
-
defaultDockerImage
|
|
171
|
+
"Docker image to use. Defaults to the selected engine's image."
|
|
175
172
|
).option(
|
|
176
173
|
"--docker-entrypoint <DOCKER_ENTRYPOINT>",
|
|
177
174
|
"Override the image entrypoint"
|
|
@@ -180,10 +177,10 @@ function registerCommands(program) {
|
|
|
180
177
|
'Extra options to pass to the docker run command, e.g. "--add-host=internal.host:192.168.11.12" (can be added multiple times).'
|
|
181
178
|
).option(
|
|
182
179
|
"--no-docker",
|
|
183
|
-
"Do not use Docker, run the engine serve command in current user environment."
|
|
180
|
+
"Do not use Docker, run the engine serve command in the current user environment."
|
|
184
181
|
).option(
|
|
185
182
|
"--site-name",
|
|
186
|
-
"Name for site when using default config",
|
|
183
|
+
"Name for site when using the default config",
|
|
187
184
|
"Documentation Site"
|
|
188
185
|
).option("-p, --port <PORT>", "Port to serve documentation locally", "8000").option("-v, --verbose", "Enable verbose output.", false).option(
|
|
189
186
|
"--engine <ENGINE>",
|
|
@@ -193,8 +190,7 @@ function registerCommands(program) {
|
|
|
193
190
|
"[Deprecated: use serve:raw] Serve a documentation project locally."
|
|
194
191
|
).option(
|
|
195
192
|
"-i, --docker-image <DOCKER_IMAGE>",
|
|
196
|
-
"
|
|
197
|
-
defaultDockerImage
|
|
193
|
+
"Docker image to use. Defaults to the selected engine's image."
|
|
198
194
|
).option(
|
|
199
195
|
"--docker-entrypoint <DOCKER_ENTRYPOINT>",
|
|
200
196
|
"Override the image entrypoint"
|
|
@@ -206,22 +202,19 @@ function registerCommands(program) {
|
|
|
206
202
|
"Do not use Docker, run `mkdocs serve` in current user environment."
|
|
207
203
|
).option(
|
|
208
204
|
"--site-name",
|
|
209
|
-
"Name for site when using default
|
|
205
|
+
"Name for site when using the default config",
|
|
210
206
|
"Documentation Site"
|
|
211
207
|
).option("-p, --port <PORT>", "Port to serve documentation locally", "8000").option("-v, --verbose", "Enable verbose output.", false).option(
|
|
212
208
|
"--engine <ENGINE>",
|
|
213
209
|
"Documentation engine to use. Overrides the backstage.io/techdocs-engine annotation in catalog-info.yaml; defaults to mkdocs."
|
|
214
|
-
).hook("preAction", () => {
|
|
215
|
-
|
|
216
|
-
"serve:mkdocs is deprecated and will be removed in a future release. Use serve:raw instead.\n"
|
|
217
|
-
);
|
|
210
|
+
).hook("preAction", (command) => {
|
|
211
|
+
command.setOptionValue("deprecatedCommandAlias", "serve:mkdocs");
|
|
218
212
|
}).action(serveRawAction);
|
|
219
213
|
program.command("serve").description(
|
|
220
214
|
"Serve a documentation project locally in a Backstage app-like environment"
|
|
221
215
|
).option(
|
|
222
216
|
"-i, --docker-image <DOCKER_IMAGE>",
|
|
223
|
-
"
|
|
224
|
-
defaultDockerImage
|
|
217
|
+
"Docker image to use. Defaults to the selected engine's image."
|
|
225
218
|
).option(
|
|
226
219
|
"--docker-entrypoint <DOCKER_ENTRYPOINT>",
|
|
227
220
|
"Override the image entrypoint"
|
|
@@ -230,15 +223,14 @@ function registerCommands(program) {
|
|
|
230
223
|
'Extra options to pass to the docker run command, e.g. "--add-host=internal.host:192.168.11.12" (can be added multiple times).'
|
|
231
224
|
).option(
|
|
232
225
|
"--no-docker",
|
|
233
|
-
"Do not use Docker,
|
|
226
|
+
"Do not use Docker, run the engine in the current user environment."
|
|
234
227
|
).option(
|
|
235
228
|
"--site-name",
|
|
236
|
-
"Name for site when using default
|
|
229
|
+
"Name for site when using the default config",
|
|
237
230
|
"Documentation Site"
|
|
238
231
|
).option(
|
|
239
232
|
"--engine-port <PORT>",
|
|
240
|
-
"Port for the documentation engine server (MkDocs, Zensical, etc.) to listen on. The Backstage preview app is served on --preview-app-port."
|
|
241
|
-
"8000"
|
|
233
|
+
"Port for the documentation engine server (MkDocs, Zensical, etc.) to listen on. Defaults to 8000. The Backstage preview app is served on --preview-app-port."
|
|
242
234
|
).option(
|
|
243
235
|
"--mkdocs-port <PORT>",
|
|
244
236
|
"[Deprecated: use --engine-port] Port for MkDocs server to use"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../src/commands/index.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 { Command } from 'commander';\nimport { TechdocsGenerator } from '@backstage/plugin-techdocs-node';\n\nconst defaultDockerImage = TechdocsGenerator.defaultDockerImage;\nconst defaultPreviewAppPort = '3000';\n\nexport function registerCommands(program: Command) {\n program\n .command('generate')\n .description('Generate TechDocs documentation site using MkDocs.')\n .option(\n '--source-dir <PATH>',\n 'Source directory containing mkdocs.yml and docs/ directory.',\n '.',\n )\n .option(\n '--output-dir <PATH>',\n 'Output directory containing generated TechDocs site.',\n './site/',\n )\n .option(\n '--docker-image <DOCKER_IMAGE>',\n 'The mkdocs docker container to use',\n defaultDockerImage,\n )\n .option('--no-pull', 'Do not pull the latest docker image')\n .option(\n '--no-docker',\n 'Do not use Docker, use MkDocs executable and plugins in current user environment.',\n )\n .option(\n '--techdocs-ref <HOST_TYPE:URL>',\n 'The repository hosting documentation source files e.g. url:https://ghe.mycompany.net.com/org/repo.' +\n '\\nThis value is same as the backstage.io/techdocs-ref annotation of the corresponding Backstage entity.' +\n '\\nIt is completely fine to skip this as it is only being used to set repo_url in mkdocs.yml if not found.\\n',\n )\n .option(\n '--etag <ETAG>',\n 'A unique identifier for the prepared tree e.g. commit SHA. If provided it will be stored in techdocs_metadata.json.' +\n ' If omitted, a sha256 content hash of the generated site output is computed automatically.',\n )\n .option(\n '--site-name',\n 'Name for site when using default MkDocs config',\n 'Documentation Site',\n )\n .option('-v, --verbose', 'Enable verbose output.', false)\n .option(\n '--omitTechdocsCoreMkdocsPlugin',\n \"Don't patch MkDocs file automatically with techdocs-core plugin.\",\n false,\n )\n .option(\n '--legacyCopyReadmeMdToIndexMd',\n 'Attempt to ensure an index.md exists falling back to using <docs-dir>/README.md or README.md in case a default <docs-dir>/index.md is not provided.',\n false,\n )\n .option(\n '--disableExternalFonts',\n 'Disable external font downloads by default by setting theme.font: false in mkdocs.yml when not already configured. Useful for air-gapped environments where Google fonts cannot be accessed.',\n false,\n )\n .option(\n '--defaultPlugin [defaultPlugins...]',\n 'Plugins which should be added automatically to the mkdocs.yaml file',\n [],\n )\n .option(\n '--dangerouslyAllowAdditionalKeys [additionalKeys...]',\n 'Top-level mkdocs.yml keys to allow beyond the built-in supported set, without failing or stripping them. Same as the techdocs.generator.mkdocs.dangerouslyAllowAdditionalKeys backend config option, which techdocs-cli generate does not currently read from a config file.',\n [],\n )\n .option(\n '--runAsDefaultUser',\n 'Bypass setting the container user as the same user and group id as host for Linux and MacOS',\n false,\n )\n .option(\n '--engine <ENGINE>',\n 'Documentation engine to use. Overrides the backstage.io/techdocs-engine annotation in catalog-info.yaml; defaults to mkdocs.',\n )\n .alias('build')\n .action(lazy(() => import('./generate/generate'), 'default'));\n\n program\n .command('migrate')\n .description(\n 'Migrate objects with case-sensitive entity triplets to lower-case versions.',\n )\n .requiredOption(\n '--publisher-type <TYPE>',\n '(Required always) awsS3 | googleGcs | azureBlobStorage | openStackSwift - same as techdocs.publisher.type in Backstage app-config.yaml',\n )\n .requiredOption(\n '--storage-name <BUCKET/CONTAINER NAME>',\n '(Required always) In case of AWS/GCS, use the bucket name. In case of Azure, use container name. Same as techdocs.publisher.[TYPE].bucketName',\n )\n .option(\n '--azureAccountName <AZURE ACCOUNT NAME>',\n '(Required for Azure) specify when --publisher-type azureBlobStorage',\n )\n .option(\n '--azureAccountKey <AZURE ACCOUNT KEY>',\n 'Azure Storage Account key to use for authentication. If not specified, you must set AZURE_TENANT_ID, AZURE_CLIENT_ID & AZURE_CLIENT_SECRET as environment variables.',\n )\n .option(\n '--awsRoleArn <AWS ROLE ARN>',\n 'Optional AWS ARN of role to be assumed.',\n )\n .option(\n '--awsEndpoint <AWS ENDPOINT>',\n 'Optional AWS endpoint to send requests to.',\n )\n .option(\n '--awsS3ForcePathStyle',\n 'Optional AWS S3 option to force path style.',\n )\n .option(\n '--osCredentialId <OPENSTACK SWIFT APPLICATION CREDENTIAL ID>',\n '(Required for OpenStack) specify when --publisher-type openStackSwift',\n )\n .option(\n '--osSecret <OPENSTACK SWIFT APPLICATION CREDENTIAL SECRET>',\n '(Required for OpenStack) specify when --publisher-type openStackSwift',\n )\n .option(\n '--osAuthUrl <OPENSTACK SWIFT AUTHURL>',\n '(Required for OpenStack) specify when --publisher-type openStackSwift',\n )\n .option(\n '--osSwiftUrl <OPENSTACK SWIFT SWIFTURL>',\n '(Required for OpenStack) specify when --publisher-type openStackSwift',\n )\n .option(\n '--removeOriginal',\n 'Optional Files are copied by default. If flag is set, files are renamed/moved instead.',\n false,\n )\n .option(\n '--concurrency <MAX CONCURRENT REQS>',\n 'Optional Controls the number of API requests allowed to be performed simultaneously.',\n '25',\n )\n .option('-v, --verbose', 'Enable verbose output.', false)\n .action(lazy(() => import('./migrate/migrate'), 'default'));\n\n program\n .command('publish')\n .description(\n 'Publish generated TechDocs site to an external storage AWS S3, Google GCS, etc.',\n )\n .requiredOption(\n '--publisher-type <TYPE>',\n '(Required always) awsS3 | googleGcs | azureBlobStorage | openStackSwift - same as techdocs.publisher.type in Backstage app-config.yaml',\n )\n .requiredOption(\n '--storage-name <BUCKET/CONTAINER NAME>',\n '(Required always) In case of AWS/GCS, use the bucket name. In case of Azure, use container name. Same as techdocs.publisher.[TYPE].bucketName',\n )\n .requiredOption(\n '--entity <NAMESPACE/KIND/NAME>',\n '(Required always) Entity uid separated by / in namespace/kind/name order (case-sensitive). Example: default/Component/myEntity ',\n )\n .option(\n '--legacyUseCaseSensitiveTripletPaths',\n 'Publishes objects with cased entity triplet prefix when set (e.g. namespace/Kind/name). Only use if your TechDocs backend is configured the same way.',\n false,\n )\n .option(\n '--azureAccountName <AZURE ACCOUNT NAME>',\n '(Required for Azure) specify when --publisher-type azureBlobStorage',\n )\n .option(\n '--azureAccountKey <AZURE ACCOUNT KEY>',\n 'Azure Storage Account key to use for authentication. If not specified, you must set AZURE_TENANT_ID, AZURE_CLIENT_ID & AZURE_CLIENT_SECRET as environment variables.',\n )\n .option(\n '--awsRoleArn <AWS ROLE ARN>',\n 'Optional AWS ARN of role to be assumed.',\n )\n .option(\n '--awsEndpoint <AWS ENDPOINT>',\n 'Optional AWS endpoint to send requests to.',\n )\n .option(\n '--awsProxy <HTTPS Proxy>',\n 'Optional Proxy to use for AWS requests.',\n )\n .option('--awsS3sse <AWS SSE>', 'Optional AWS S3 Server Side Encryption.')\n .option(\n '--awsS3ForcePathStyle',\n 'Optional AWS S3 option to force path style.',\n )\n .option(\n '--awsBucketRootPath <AWS BUCKET ROOT PATH>',\n 'Optional sub-directory to store files in Amazon S3',\n )\n .option(\n '--awsMaxAttempts <AWS MAX ATTEMPTS>',\n 'Optional maximum number of retries for AWS S3 operations. If not specified, default value of 3 is used.',\n )\n .option(\n '--osCredentialId <OPENSTACK SWIFT APPLICATION CREDENTIAL ID>',\n '(Required for OpenStack) specify when --publisher-type openStackSwift',\n )\n .option(\n '--osSecret <OPENSTACK SWIFT APPLICATION CREDENTIAL SECRET>',\n '(Required for OpenStack) specify when --publisher-type openStackSwift',\n )\n .option(\n '--osAuthUrl <OPENSTACK SWIFT AUTHURL>',\n '(Required for OpenStack) specify when --publisher-type openStackSwift',\n )\n .option(\n '--osSwiftUrl <OPENSTACK SWIFT SWIFTURL>',\n '(Required for OpenStack) specify when --publisher-type openStackSwift',\n )\n .option(\n '--gcsBucketRootPath <GCS BUCKET ROOT PATH>',\n 'Optional sub-directory to store files in Google cloud storage',\n )\n .option(\n '--directory <PATH>',\n 'Path of the directory containing generated files to publish',\n './site/',\n )\n .option(\n '--skip-if-unchanged',\n 'Skip publishing if the local etag in techdocs_metadata.json matches the remote etag.' +\n ' The generate step computes a generated site content hash automatically unless --etag is overridden.',\n false,\n )\n .action(lazy(() => import('./publish/publish'), 'default'));\n\n const serveRawAction = lazy(() => import('./serve/mkdocs'), 'default');\n\n program\n .command('serve:raw')\n .description(\n 'Serve a documentation project locally using the configured engine.',\n )\n .option(\n '-i, --docker-image <DOCKER_IMAGE>',\n 'The docker container to use',\n defaultDockerImage,\n )\n .option(\n '--docker-entrypoint <DOCKER_ENTRYPOINT>',\n 'Override the image entrypoint',\n )\n .option(\n '--docker-option <DOCKER_OPTION...>',\n 'Extra options to pass to the docker run command, e.g. \"--add-host=internal.host:192.168.11.12\" (can be added multiple times).',\n )\n .option(\n '--no-docker',\n 'Do not use Docker, run the engine serve command in current user environment.',\n )\n .option(\n '--site-name',\n 'Name for site when using default config',\n 'Documentation Site',\n )\n .option('-p, --port <PORT>', 'Port to serve documentation locally', '8000')\n .option('-v, --verbose', 'Enable verbose output.', false)\n .option(\n '--engine <ENGINE>',\n 'Documentation engine to use. Overrides the backstage.io/techdocs-engine annotation in catalog-info.yaml; defaults to mkdocs.',\n )\n .action(serveRawAction);\n\n program\n .command('serve:mkdocs')\n .description(\n '[Deprecated: use serve:raw] Serve a documentation project locally.',\n )\n .option(\n '-i, --docker-image <DOCKER_IMAGE>',\n 'The mkdocs docker container to use',\n defaultDockerImage,\n )\n .option(\n '--docker-entrypoint <DOCKER_ENTRYPOINT>',\n 'Override the image entrypoint',\n )\n .option(\n '--docker-option <DOCKER_OPTION...>',\n 'Extra options to pass to the docker run command, e.g. \"--add-host=internal.host:192.168.11.12\" (can be added multiple times).',\n )\n .option(\n '--no-docker',\n 'Do not use Docker, run `mkdocs serve` in current user environment.',\n )\n .option(\n '--site-name',\n 'Name for site when using default MkDocs config',\n 'Documentation Site',\n )\n .option('-p, --port <PORT>', 'Port to serve documentation locally', '8000')\n .option('-v, --verbose', 'Enable verbose output.', false)\n .option(\n '--engine <ENGINE>',\n 'Documentation engine to use. Overrides the backstage.io/techdocs-engine annotation in catalog-info.yaml; defaults to mkdocs.',\n )\n .hook('preAction', () => {\n process.stderr.write(\n 'serve:mkdocs is deprecated and will be removed in a future release. Use serve:raw instead.\\n',\n );\n })\n .action(serveRawAction);\n\n program\n .command('serve')\n .description(\n 'Serve a documentation project locally in a Backstage app-like environment',\n )\n .option(\n '-i, --docker-image <DOCKER_IMAGE>',\n 'The mkdocs docker container to use',\n defaultDockerImage,\n )\n .option(\n '--docker-entrypoint <DOCKER_ENTRYPOINT>',\n 'Override the image entrypoint',\n )\n .option(\n '--docker-option <DOCKER_OPTION...>',\n 'Extra options to pass to the docker run command, e.g. \"--add-host=internal.host:192.168.11.12\" (can be added multiple times).',\n )\n .option(\n '--no-docker',\n 'Do not use Docker, use MkDocs executable in current user environment.',\n )\n .option(\n '--site-name',\n 'Name for site when using default MkDocs config',\n 'Documentation Site',\n )\n .option(\n '--engine-port <PORT>',\n 'Port for the documentation engine server (MkDocs, Zensical, etc.) to listen on. The Backstage preview app is served on --preview-app-port.',\n '8000',\n )\n .option(\n '--mkdocs-port <PORT>',\n '[Deprecated: use --engine-port] Port for MkDocs server to use',\n )\n .option('-v, --verbose', 'Enable verbose output.', false)\n .option(\n '--preview-app-bundle-path <PATH_TO_BUNDLE>',\n 'Preview documentation using another web app',\n )\n .option(\n '--preview-app-port <PORT>',\n 'Port for the preview app to be served on',\n defaultPreviewAppPort,\n )\n .option(\n '-c, --config-file-name <FILENAME>',\n 'Config file name for the documentation engine (e.g. mkdocs.yml). Overrides automatic detection.',\n )\n .option(\n '--mkdocs-config-file-name <FILENAME>',\n '[Deprecated: use --config-file-name] Mkdocs config file name',\n )\n .option(\n '--parameter-clean',\n 'Pass \"--clean\" to the documentation engine server. Clears the build cache before serving.',\n false,\n )\n .option(\n '--mkdocs-parameter-clean',\n '[Deprecated: use --parameter-clean] Pass \"--clean\" parameter to mkdocs server',\n false,\n )\n .option(\n '--parameter-dirtyreload',\n 'Pass \"--dirtyreload\" to the documentation engine server. Only rebuilds changed files on reload (MkDocs only; ignored by other engines).',\n false,\n )\n .option(\n '--mkdocs-parameter-dirtyreload',\n '[Deprecated: use --parameter-dirtyreload] Pass \"--dirtyreload\" parameter to mkdocs server',\n false,\n )\n .option(\n '--parameter-strict',\n 'Pass \"--strict\" to the documentation engine server. Treats warnings as errors during build.',\n false,\n )\n .option(\n '--mkdocs-parameter-strict',\n '[Deprecated: use --parameter-strict] Pass \"--strict\" parameter to mkdocs server',\n false,\n )\n .option(\n '--engine <ENGINE>',\n 'Documentation engine to use. Overrides the backstage.io/techdocs-engine annotation in catalog-info.yaml; defaults to mkdocs.',\n )\n .hook('preAction', command => {\n if (\n command.opts().previewAppPort !== defaultPreviewAppPort &&\n !command.opts().previewAppBundlePath\n ) {\n command.error(\n '--preview-app-port can only be used together with --preview-app-bundle-path',\n );\n }\n })\n .action(lazy(() => import('./serve/serve'), 'default'));\n}\n\n// Humbly taken from backstage-cli's registerCommands\ntype ActionFunc = (...args: any[]) => Promise<void>;\ntype ActionExports<TModule extends object> = {\n [KName in keyof TModule as TModule[KName] extends ActionFunc\n ? KName\n : never]: TModule[KName];\n};\n\n// Wraps an action function so that it always exits and handles errors\nexport function lazy<TModule extends object>(\n moduleLoader: () => Promise<TModule>,\n exportName: keyof ActionExports<TModule>,\n): (...args: any[]) => Promise<never> {\n return async (...args: any[]) => {\n try {\n const mod = await moduleLoader();\n const actualModule = (\n mod as unknown as { default: ActionExports<TModule> }\n ).default;\n const actionFunc = actualModule[exportName] as ActionFunc;\n await actionFunc(...args);\n\n process.exit(0);\n } catch (error) {\n console.error(error.message);\n process.exit(1);\n }\n };\n}\n"],"names":["TechdocsGenerator"],"mappings":";;;;AAmBA,MAAM,qBAAqBA,oCAAA,CAAkB,kBAAA;AAC7C,MAAM,qBAAA,GAAwB,MAAA;AAEvB,SAAS,iBAAiB,OAAA,EAAk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AC,CAAA;AAC1D;AAWO,SAAS,IAAA,CACd,cACA,UAAA,EACoC;AACpC,EAAA,OAAO,UAAU,IAAA,KAAgB;AAC/B,IAAA,IAAI;AACF,MAAA,MAAM,GAAA,GAAM,MAAM,YAAA,EAAa;AAC/B,MAAA,MAAM,eACJ,GAAA,CACA,OAAA;AACF,MAAA,MAAM,UAAA,GAAa,aAAa,UAAU,CAAA;AAC1C,MAAA,MAAM,UAAA,CAAW,GAAG,IAAI,CAAA;AAExB,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB,SAAS,KAAA,EAAO;AACd,MAAA,OAAA,CAAQ,KAAA,CAAM,MAAM,OAAO,CAAA;AAC3B,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB;AAAA,EACF,CAAA;AACF;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../src/commands/index.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 { Command } from 'commander';\n\nconst defaultPreviewAppPort = '3000';\n\nexport function registerCommands(program: Command) {\n program\n .command('generate')\n .description(\n 'Generate a TechDocs documentation site with the selected engine (MkDocs by default).',\n )\n .option(\n '--source-dir <PATH>',\n 'Source directory containing mkdocs.yml and docs/ directory.',\n '.',\n )\n .option(\n '--output-dir <PATH>',\n 'Output directory containing generated TechDocs site.',\n './site/',\n )\n .option(\n '--docker-image <DOCKER_IMAGE>',\n \"Docker image to use. Defaults to the selected engine's image.\",\n )\n .option('--no-pull', 'Do not pull the latest docker image')\n .option(\n '--no-docker',\n 'Do not use Docker, run the engine and its plugins in the current user environment.',\n )\n .option(\n '--techdocs-ref <HOST_TYPE:URL>',\n 'The repository hosting documentation source files e.g. url:https://ghe.mycompany.net.com/org/repo.' +\n '\\nThis value is same as the backstage.io/techdocs-ref annotation of the corresponding Backstage entity.' +\n '\\nIt is completely fine to skip this as it is only being used to set repo_url in mkdocs.yml if not found.\\n',\n )\n .option(\n '--etag <ETAG>',\n 'A unique identifier for the prepared tree e.g. commit SHA. If provided it will be stored in techdocs_metadata.json.' +\n ' If omitted, a sha256 content hash of the generated site output is computed automatically.',\n )\n .option(\n '--site-name',\n 'Name for site when using the default config',\n 'Documentation Site',\n )\n .option('-v, --verbose', 'Enable verbose output.', false)\n .option(\n '--omitTechdocsCoreMkdocsPlugin',\n \"Don't patch MkDocs file automatically with techdocs-core plugin.\",\n false,\n )\n .option(\n '--legacyCopyReadmeMdToIndexMd',\n 'Attempt to ensure an index.md exists falling back to using <docs-dir>/README.md or README.md in case a default <docs-dir>/index.md is not provided.',\n false,\n )\n .option(\n '--disableExternalFonts',\n 'Disable external font downloads by default by setting theme.font: false in mkdocs.yml when not already configured. Useful for air-gapped environments where Google fonts cannot be accessed.',\n false,\n )\n .option(\n '--defaultPlugin [defaultPlugins...]',\n 'Plugins which should be added automatically to the mkdocs.yaml file',\n [],\n )\n .option(\n '--dangerouslyAllowAdditionalKeys [additionalKeys...]',\n 'Top-level mkdocs.yml keys to allow beyond the built-in supported set, without failing or stripping them. Same as the techdocs.generator.mkdocs.dangerouslyAllowAdditionalKeys backend config option, which techdocs-cli generate does not currently read from a config file.',\n [],\n )\n .option(\n '--runAsDefaultUser',\n 'Bypass setting the container user as the same user and group id as host for Linux and MacOS',\n false,\n )\n .option(\n '--engine <ENGINE>',\n 'Documentation engine to use. Overrides the backstage.io/techdocs-engine annotation in catalog-info.yaml; defaults to mkdocs.',\n )\n .alias('build')\n .action(lazy(() => import('./generate/generate'), 'default'));\n\n program\n .command('migrate')\n .description(\n 'Migrate objects with case-sensitive entity triplets to lower-case versions.',\n )\n .requiredOption(\n '--publisher-type <TYPE>',\n '(Required always) awsS3 | googleGcs | azureBlobStorage | openStackSwift - same as techdocs.publisher.type in Backstage app-config.yaml',\n )\n .requiredOption(\n '--storage-name <BUCKET/CONTAINER NAME>',\n '(Required always) In case of AWS/GCS, use the bucket name. In case of Azure, use container name. Same as techdocs.publisher.[TYPE].bucketName',\n )\n .option(\n '--azureAccountName <AZURE ACCOUNT NAME>',\n '(Required for Azure) specify when --publisher-type azureBlobStorage',\n )\n .option(\n '--azureAccountKey <AZURE ACCOUNT KEY>',\n 'Azure Storage Account key to use for authentication. If not specified, you must set AZURE_TENANT_ID, AZURE_CLIENT_ID & AZURE_CLIENT_SECRET as environment variables.',\n )\n .option(\n '--awsRoleArn <AWS ROLE ARN>',\n 'Optional AWS ARN of role to be assumed.',\n )\n .option(\n '--awsEndpoint <AWS ENDPOINT>',\n 'Optional AWS endpoint to send requests to.',\n )\n .option(\n '--awsS3ForcePathStyle',\n 'Optional AWS S3 option to force path style.',\n )\n .option(\n '--osCredentialId <OPENSTACK SWIFT APPLICATION CREDENTIAL ID>',\n '(Required for OpenStack) specify when --publisher-type openStackSwift',\n )\n .option(\n '--osSecret <OPENSTACK SWIFT APPLICATION CREDENTIAL SECRET>',\n '(Required for OpenStack) specify when --publisher-type openStackSwift',\n )\n .option(\n '--osAuthUrl <OPENSTACK SWIFT AUTHURL>',\n '(Required for OpenStack) specify when --publisher-type openStackSwift',\n )\n .option(\n '--osSwiftUrl <OPENSTACK SWIFT SWIFTURL>',\n '(Required for OpenStack) specify when --publisher-type openStackSwift',\n )\n .option(\n '--removeOriginal',\n 'Optional Files are copied by default. If flag is set, files are renamed/moved instead.',\n false,\n )\n .option(\n '--concurrency <MAX CONCURRENT REQS>',\n 'Optional Controls the number of API requests allowed to be performed simultaneously.',\n '25',\n )\n .option('-v, --verbose', 'Enable verbose output.', false)\n .action(lazy(() => import('./migrate/migrate'), 'default'));\n\n program\n .command('publish')\n .description(\n 'Publish generated TechDocs site to an external storage AWS S3, Google GCS, etc.',\n )\n .requiredOption(\n '--publisher-type <TYPE>',\n '(Required always) awsS3 | googleGcs | azureBlobStorage | openStackSwift - same as techdocs.publisher.type in Backstage app-config.yaml',\n )\n .requiredOption(\n '--storage-name <BUCKET/CONTAINER NAME>',\n '(Required always) In case of AWS/GCS, use the bucket name. In case of Azure, use container name. Same as techdocs.publisher.[TYPE].bucketName',\n )\n .requiredOption(\n '--entity <NAMESPACE/KIND/NAME>',\n '(Required always) Entity uid separated by / in namespace/kind/name order (case-sensitive). Example: default/Component/myEntity ',\n )\n .option(\n '--legacyUseCaseSensitiveTripletPaths',\n 'Publishes objects with cased entity triplet prefix when set (e.g. namespace/Kind/name). Only use if your TechDocs backend is configured the same way.',\n false,\n )\n .option(\n '--azureAccountName <AZURE ACCOUNT NAME>',\n '(Required for Azure) specify when --publisher-type azureBlobStorage',\n )\n .option(\n '--azureAccountKey <AZURE ACCOUNT KEY>',\n 'Azure Storage Account key to use for authentication. If not specified, you must set AZURE_TENANT_ID, AZURE_CLIENT_ID & AZURE_CLIENT_SECRET as environment variables.',\n )\n .option(\n '--awsRoleArn <AWS ROLE ARN>',\n 'Optional AWS ARN of role to be assumed.',\n )\n .option(\n '--awsEndpoint <AWS ENDPOINT>',\n 'Optional AWS endpoint to send requests to.',\n )\n .option(\n '--awsProxy <HTTPS Proxy>',\n 'Optional Proxy to use for AWS requests.',\n )\n .option('--awsS3sse <AWS SSE>', 'Optional AWS S3 Server Side Encryption.')\n .option(\n '--awsS3ForcePathStyle',\n 'Optional AWS S3 option to force path style.',\n )\n .option(\n '--awsBucketRootPath <AWS BUCKET ROOT PATH>',\n 'Optional sub-directory to store files in Amazon S3',\n )\n .option(\n '--awsMaxAttempts <AWS MAX ATTEMPTS>',\n 'Optional maximum number of retries for AWS S3 operations. If not specified, default value of 3 is used.',\n )\n .option(\n '--osCredentialId <OPENSTACK SWIFT APPLICATION CREDENTIAL ID>',\n '(Required for OpenStack) specify when --publisher-type openStackSwift',\n )\n .option(\n '--osSecret <OPENSTACK SWIFT APPLICATION CREDENTIAL SECRET>',\n '(Required for OpenStack) specify when --publisher-type openStackSwift',\n )\n .option(\n '--osAuthUrl <OPENSTACK SWIFT AUTHURL>',\n '(Required for OpenStack) specify when --publisher-type openStackSwift',\n )\n .option(\n '--osSwiftUrl <OPENSTACK SWIFT SWIFTURL>',\n '(Required for OpenStack) specify when --publisher-type openStackSwift',\n )\n .option(\n '--gcsBucketRootPath <GCS BUCKET ROOT PATH>',\n 'Optional sub-directory to store files in Google cloud storage',\n )\n .option(\n '--directory <PATH>',\n 'Path of the directory containing generated files to publish',\n './site/',\n )\n .option(\n '--skip-if-unchanged',\n 'Skip publishing if the local etag in techdocs_metadata.json matches the remote etag.' +\n ' The generate step computes a generated site content hash automatically unless --etag is overridden.',\n false,\n )\n .action(lazy(() => import('./publish/publish'), 'default'));\n\n const serveRawAction = lazy(() => import('./serve/mkdocs'), 'default');\n\n program\n .command('serve:raw')\n .description(\n 'Serve a documentation project locally using the configured engine.',\n )\n .option(\n '-i, --docker-image <DOCKER_IMAGE>',\n \"Docker image to use. Defaults to the selected engine's image.\",\n )\n .option(\n '--docker-entrypoint <DOCKER_ENTRYPOINT>',\n 'Override the image entrypoint',\n )\n .option(\n '--docker-option <DOCKER_OPTION...>',\n 'Extra options to pass to the docker run command, e.g. \"--add-host=internal.host:192.168.11.12\" (can be added multiple times).',\n )\n .option(\n '--no-docker',\n 'Do not use Docker, run the engine serve command in the current user environment.',\n )\n .option(\n '--site-name',\n 'Name for site when using the default config',\n 'Documentation Site',\n )\n .option('-p, --port <PORT>', 'Port to serve documentation locally', '8000')\n .option('-v, --verbose', 'Enable verbose output.', false)\n .option(\n '--engine <ENGINE>',\n 'Documentation engine to use. Overrides the backstage.io/techdocs-engine annotation in catalog-info.yaml; defaults to mkdocs.',\n )\n .action(serveRawAction);\n\n program\n .command('serve:mkdocs')\n .description(\n '[Deprecated: use serve:raw] Serve a documentation project locally.',\n )\n .option(\n '-i, --docker-image <DOCKER_IMAGE>',\n \"Docker image to use. Defaults to the selected engine's image.\",\n )\n .option(\n '--docker-entrypoint <DOCKER_ENTRYPOINT>',\n 'Override the image entrypoint',\n )\n .option(\n '--docker-option <DOCKER_OPTION...>',\n 'Extra options to pass to the docker run command, e.g. \"--add-host=internal.host:192.168.11.12\" (can be added multiple times).',\n )\n .option(\n '--no-docker',\n 'Do not use Docker, run `mkdocs serve` in current user environment.',\n )\n .option(\n '--site-name',\n 'Name for site when using the default config',\n 'Documentation Site',\n )\n .option('-p, --port <PORT>', 'Port to serve documentation locally', '8000')\n .option('-v, --verbose', 'Enable verbose output.', false)\n .option(\n '--engine <ENGINE>',\n 'Documentation engine to use. Overrides the backstage.io/techdocs-engine annotation in catalog-info.yaml; defaults to mkdocs.',\n )\n .hook('preAction', command => {\n command.setOptionValue('deprecatedCommandAlias', 'serve:mkdocs');\n })\n .action(serveRawAction);\n\n program\n .command('serve')\n .description(\n 'Serve a documentation project locally in a Backstage app-like environment',\n )\n .option(\n '-i, --docker-image <DOCKER_IMAGE>',\n \"Docker image to use. Defaults to the selected engine's image.\",\n )\n .option(\n '--docker-entrypoint <DOCKER_ENTRYPOINT>',\n 'Override the image entrypoint',\n )\n .option(\n '--docker-option <DOCKER_OPTION...>',\n 'Extra options to pass to the docker run command, e.g. \"--add-host=internal.host:192.168.11.12\" (can be added multiple times).',\n )\n .option(\n '--no-docker',\n 'Do not use Docker, run the engine in the current user environment.',\n )\n .option(\n '--site-name',\n 'Name for site when using the default config',\n 'Documentation Site',\n )\n .option(\n '--engine-port <PORT>',\n 'Port for the documentation engine server (MkDocs, Zensical, etc.) to listen on. Defaults to 8000. The Backstage preview app is served on --preview-app-port.',\n )\n .option(\n '--mkdocs-port <PORT>',\n '[Deprecated: use --engine-port] Port for MkDocs server to use',\n )\n .option('-v, --verbose', 'Enable verbose output.', false)\n .option(\n '--preview-app-bundle-path <PATH_TO_BUNDLE>',\n 'Preview documentation using another web app',\n )\n .option(\n '--preview-app-port <PORT>',\n 'Port for the preview app to be served on',\n defaultPreviewAppPort,\n )\n .option(\n '-c, --config-file-name <FILENAME>',\n 'Config file name for the documentation engine (e.g. mkdocs.yml). Overrides automatic detection.',\n )\n .option(\n '--mkdocs-config-file-name <FILENAME>',\n '[Deprecated: use --config-file-name] Mkdocs config file name',\n )\n .option(\n '--parameter-clean',\n 'Pass \"--clean\" to the documentation engine server. Clears the build cache before serving.',\n false,\n )\n .option(\n '--mkdocs-parameter-clean',\n '[Deprecated: use --parameter-clean] Pass \"--clean\" parameter to mkdocs server',\n false,\n )\n .option(\n '--parameter-dirtyreload',\n 'Pass \"--dirtyreload\" to the documentation engine server. Only rebuilds changed files on reload (MkDocs only; ignored by other engines).',\n false,\n )\n .option(\n '--mkdocs-parameter-dirtyreload',\n '[Deprecated: use --parameter-dirtyreload] Pass \"--dirtyreload\" parameter to mkdocs server',\n false,\n )\n .option(\n '--parameter-strict',\n 'Pass \"--strict\" to the documentation engine server. Treats warnings as errors during build.',\n false,\n )\n .option(\n '--mkdocs-parameter-strict',\n '[Deprecated: use --parameter-strict] Pass \"--strict\" parameter to mkdocs server',\n false,\n )\n .option(\n '--engine <ENGINE>',\n 'Documentation engine to use. Overrides the backstage.io/techdocs-engine annotation in catalog-info.yaml; defaults to mkdocs.',\n )\n .hook('preAction', command => {\n if (\n command.opts().previewAppPort !== defaultPreviewAppPort &&\n !command.opts().previewAppBundlePath\n ) {\n command.error(\n '--preview-app-port can only be used together with --preview-app-bundle-path',\n );\n }\n })\n .action(lazy(() => import('./serve/serve'), 'default'));\n}\n\n// Humbly taken from backstage-cli's registerCommands\ntype ActionFunc = (...args: any[]) => Promise<void>;\ntype ActionExports<TModule extends object> = {\n [KName in keyof TModule as TModule[KName] extends ActionFunc\n ? KName\n : never]: TModule[KName];\n};\n\n// Wraps an action function so that it always exits and handles errors\nexport function lazy<TModule extends object>(\n moduleLoader: () => Promise<TModule>,\n exportName: keyof ActionExports<TModule>,\n): (...args: any[]) => Promise<never> {\n return async (...args: any[]) => {\n try {\n const mod = await moduleLoader();\n const actualModule = (\n mod as unknown as { default: ActionExports<TModule> }\n ).default;\n const actionFunc = actualModule[exportName] as ActionFunc;\n await actionFunc(...args);\n\n process.exit(0);\n } catch (error) {\n console.error(error.message);\n process.exit(1);\n }\n };\n}\n"],"names":[],"mappings":";;AAkBA,MAAM,qBAAA,GAAwB,MAAA;AAEvB,SAAS,iBAAiB,OAAA,EAAkB;AACjD,EAAA,OAAA,CACG,OAAA,CAAQ,UAAU,CAAA,CAClB,WAAA;AAAA,IACC;AAAA,GACF,CACC,MAAA;AAAA,IACC,qBAAA;AAAA,IACA,6DAAA;AAAA,IACA;AAAA,GACF,CACC,MAAA;AAAA,IACC,qBAAA;AAAA,IACA,sDAAA;AAAA,IACA;AAAA,GACF,CACC,MAAA;AAAA,IACC,+BAAA;AAAA,IACA;AAAA,GACF,CACC,MAAA,CAAO,WAAA,EAAa,qCAAqC,CAAA,CACzD,MAAA;AAAA,IACC,aAAA;AAAA,IACA;AAAA,GACF,CACC,MAAA;AAAA,IACC,gCAAA;AAAA,IACA;AAAA,GAGF,CACC,MAAA;AAAA,IACC,eAAA;AAAA,IACA;AAAA,GAEF,CACC,MAAA;AAAA,IACC,aAAA;AAAA,IACA,6CAAA;AAAA,IACA;AAAA,GACF,CACC,MAAA,CAAO,eAAA,EAAiB,wBAAA,EAA0B,KAAK,CAAA,CACvD,MAAA;AAAA,IACC,gCAAA;AAAA,IACA,kEAAA;AAAA,IACA;AAAA,GACF,CACC,MAAA;AAAA,IACC,+BAAA;AAAA,IACA,qJAAA;AAAA,IACA;AAAA,GACF,CACC,MAAA;AAAA,IACC,wBAAA;AAAA,IACA,8LAAA;AAAA,IACA;AAAA,GACF,CACC,MAAA;AAAA,IACC,qCAAA;AAAA,IACA,qEAAA;AAAA,IACA;AAAC,GACH,CACC,MAAA;AAAA,IACC,sDAAA;AAAA,IACA,8QAAA;AAAA,IACA;AAAC,GACH,C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AAmB,yBAClC,CAAC,OAAA,CAAQ,IAAA,EAAK,CAAE,oBAAA,EAChB;AACA,MAAA,OAAA,CAAQ,KAAA;AAAA,QACN;AAAA,OACF;AAAA,IACF;AAAA,EACF,CAAC,EACA,MAAA,CAAO,IAAA,CAAK,MAAM,OAAO,sBAAe,CAAA,EAAG,SAAS,CAAC,CAAA;AAC1D;AAWO,SAAS,IAAA,CACd,cACA,UAAA,EACoC;AACpC,EAAA,OAAO,UAAU,IAAA,KAAgB;AAC/B,IAAA,IAAI;AACF,MAAA,MAAM,GAAA,GAAM,MAAM,YAAA,EAAa;AAC/B,MAAA,MAAM,eACJ,GAAA,CACA,OAAA;AACF,MAAA,MAAM,UAAA,GAAa,aAAa,UAAU,CAAA;AAC1C,MAAA,MAAM,UAAA,CAAW,GAAG,IAAI,CAAA;AAExB,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB,SAAS,KAAA,EAAO;AACd,MAAA,OAAA,CAAQ,KAAA,CAAM,MAAM,OAAO,CAAA;AAC3B,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB;AAAA,EACF,CAAA;AACF;;;"}
|
|
@@ -8,8 +8,9 @@ var server = require('../../lib/server.cjs.js');
|
|
|
8
8
|
var pluginTechdocsNode = require('@backstage/plugin-techdocs-node');
|
|
9
9
|
var fs = require('fs-extra');
|
|
10
10
|
var utils = require('./utils.cjs.js');
|
|
11
|
-
var
|
|
11
|
+
var registry = require('../../lib/engines/registry.cjs.js');
|
|
12
12
|
var catalogEntity = require('../../lib/catalogEntity.cjs.js');
|
|
13
|
+
var prepareServeConfig = require('../../lib/prepareServeConfig.cjs.js');
|
|
13
14
|
|
|
14
15
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
15
16
|
|
|
@@ -18,12 +19,17 @@ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
|
18
19
|
|
|
19
20
|
async function serveMkdocs(opts) {
|
|
20
21
|
const logger = utility.createLogger({ verbose: opts.verbose });
|
|
22
|
+
if (opts.deprecatedCommandAlias) {
|
|
23
|
+
logger.warn(
|
|
24
|
+
`${opts.deprecatedCommandAlias} is deprecated and will be removed in a future release. Use serve:raw instead.`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
21
27
|
const { engine, source: engineSource } = await catalogEntity.resolveEngine(
|
|
22
28
|
process.cwd(),
|
|
23
29
|
opts.engine,
|
|
24
30
|
logger
|
|
25
31
|
);
|
|
26
|
-
const engineConfig
|
|
32
|
+
const engineConfig = registry.getEngineConfig(engine, engineSource);
|
|
27
33
|
const localAddr = `http://127.0.0.1:${opts.port}`;
|
|
28
34
|
if (opts.docker) {
|
|
29
35
|
const isDockerOperational = await utils.checkIfDockerIsOperational(logger);
|
|
@@ -35,6 +41,11 @@ async function serveMkdocs(opts) {
|
|
|
35
41
|
"./",
|
|
36
42
|
opts.siteName
|
|
37
43
|
);
|
|
44
|
+
const serveConfigPath = await prepareServeConfig.prepareServeConfig(
|
|
45
|
+
engineConfig,
|
|
46
|
+
mkdocsYmlPath,
|
|
47
|
+
logger
|
|
48
|
+
);
|
|
38
49
|
let boolOpenBrowserTriggered = false;
|
|
39
50
|
const logFunc = (data) => {
|
|
40
51
|
const logLines = data.toString().split("\n");
|
|
@@ -44,7 +55,7 @@ async function serveMkdocs(opts) {
|
|
|
44
55
|
return;
|
|
45
56
|
}
|
|
46
57
|
logger.verbose(`${logPrefix} ${line}`);
|
|
47
|
-
if (!boolOpenBrowserTriggered &&
|
|
58
|
+
if (!boolOpenBrowserTriggered && engineConfig.startupLogPattern.test(line)) {
|
|
48
59
|
logger.info(`
|
|
49
60
|
Starting ${engine} server on ${localAddr}
|
|
50
61
|
`);
|
|
@@ -55,15 +66,15 @@ Starting ${engine} server on ${localAddr}
|
|
|
55
66
|
};
|
|
56
67
|
const childProcess = server.runEngineServer({
|
|
57
68
|
port: opts.port,
|
|
58
|
-
dockerImage: opts.dockerImage,
|
|
69
|
+
dockerImage: opts.dockerImage ?? engineConfig.defaultImage,
|
|
59
70
|
dockerEntrypoint: opts.dockerEntrypoint,
|
|
60
71
|
dockerOptions: opts.dockerOption,
|
|
61
72
|
useDocker: opts.docker,
|
|
62
73
|
onStdout: logFunc,
|
|
63
74
|
onStderr: logFunc,
|
|
64
|
-
engineBinary: engineConfig
|
|
65
|
-
engineServeArgs: engineConfig
|
|
66
|
-
configFile:
|
|
75
|
+
engineBinary: engineConfig.binary,
|
|
76
|
+
engineServeArgs: engineConfig.serveArgs(opts.port, {
|
|
77
|
+
configFile: serveConfigPath,
|
|
67
78
|
useDocker: opts.docker
|
|
68
79
|
})
|
|
69
80
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mkdocs.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 { runEngineServer } from '../../lib/server';\nimport { RunOnOutput } from '@backstage/cli-common';\nimport { getMkdocsYml } from '@backstage/plugin-techdocs-node';\nimport fs from 'fs-extra';\nimport { checkIfDockerIsOperational } from './utils';\nimport { getEngineConfig } from '../../lib/
|
|
1
|
+
{"version":3,"file":"mkdocs.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 { runEngineServer } from '../../lib/server';\nimport { RunOnOutput } from '@backstage/cli-common';\nimport { getMkdocsYml } from '@backstage/plugin-techdocs-node';\nimport fs from 'fs-extra';\nimport { checkIfDockerIsOperational } from './utils';\nimport { getEngineConfig } from '../../lib/engines';\nimport { resolveEngine } from '../../lib/catalogEntity';\nimport { prepareServeConfig } from '../../lib/prepareServeConfig';\n\nexport default async function serveMkdocs(opts: OptionValues) {\n const logger = createLogger({ verbose: opts.verbose });\n if (opts.deprecatedCommandAlias) {\n logger.warn(\n `${opts.deprecatedCommandAlias} is deprecated and will be removed in a future release. Use serve:raw instead.`,\n );\n }\n\n const { engine, source: engineSource } = await resolveEngine(\n process.cwd(),\n opts.engine,\n logger,\n );\n const engineConfig = getEngineConfig(engine, engineSource);\n\n const localAddr = `http://127.0.0.1:${opts.port}`;\n\n if (opts.docker) {\n const isDockerOperational = await checkIfDockerIsOperational(logger);\n if (!isDockerOperational) {\n return;\n }\n }\n\n const { path: mkdocsYmlPath, configIsTemporary } = await getMkdocsYml(\n './',\n opts.siteName,\n );\n\n const serveConfigPath = await prepareServeConfig(\n engineConfig,\n mkdocsYmlPath,\n logger,\n );\n\n // We want to open browser only once based on a log.\n let boolOpenBrowserTriggered = false;\n\n const logFunc: RunOnOutput = 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/${engine}]` : `[${engine}]`;\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 engineConfig.startupLogPattern.test(line)\n ) {\n // Always open the local address, since 0.0.0.0 belongs to docker\n logger.info(`\\nStarting ${engine} server on ${localAddr}\\n`);\n openBrowser(localAddr);\n boolOpenBrowserTriggered = true;\n }\n });\n };\n // Engines may log to stderr rather than stdout (mkdocs does, see\n // https://github.com/mkdocs/mkdocs/issues/879), so watch both streams.\n\n const childProcess = runEngineServer({\n port: opts.port,\n dockerImage: opts.dockerImage ?? engineConfig.defaultImage,\n dockerEntrypoint: opts.dockerEntrypoint,\n dockerOptions: opts.dockerOption,\n useDocker: opts.docker,\n onStdout: logFunc,\n onStderr: logFunc,\n engineBinary: engineConfig.binary,\n engineServeArgs: engineConfig.serveArgs(opts.port, {\n configFile: serveConfigPath,\n useDocker: opts.docker,\n }),\n });\n\n // Keep waiting for user to cancel the process\n await childProcess.waitForExit();\n\n if (configIsTemporary) {\n process.on('exit', async () => {\n fs.rmSync(mkdocsYmlPath, {});\n });\n }\n}\n"],"names":["createLogger","resolveEngine","getEngineConfig","checkIfDockerIsOperational","getMkdocsYml","prepareServeConfig","openBrowser","runEngineServer","fs"],"mappings":";;;;;;;;;;;;;;;;;;;AA4BA,eAA8B,YAAY,IAAA,EAAoB;AAC5D,EAAA,MAAM,SAASA,oBAAA,CAAa,EAAE,OAAA,EAAS,IAAA,CAAK,SAAS,CAAA;AACrD,EAAA,IAAI,KAAK,sBAAA,EAAwB;AAC/B,IAAA,MAAA,CAAO,IAAA;AAAA,MACL,CAAA,EAAG,KAAK,sBAAsB,CAAA,8EAAA;AAAA,KAChC;AAAA,EACF;AAEA,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,YAAA,KAAiB,MAAMC,2BAAA;AAAA,IAC7C,QAAQ,GAAA,EAAI;AAAA,IACZ,IAAA,CAAK,MAAA;AAAA,IACL;AAAA,GACF;AACA,EAAA,MAAM,YAAA,GAAeC,wBAAA,CAAgB,MAAA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GAA2B,IAAA;AAAA,MAC7B;AAAA,IACF,CAAC,CAAA;AAAA,EACH,CAAA;AAIA,EAAA,MAAM,eAAeC,sBAAA,CAAgB;AAAA,IACnC,MAAM,IAAA,CAAK,IAAA;AAAA,IACX,WAAA,EAAa,IAAA,CAAK,WAAA,IAAe,YAAA,CAAa,YAAA;AAAA,IAC9C,kBAAkB,IAAA,CAAK,gBAAA;AAAA,IACvB,eAAe,IAAA,CAAK,YAAA;AAAA,IACpB,WAAW,IAAA,CAAK,MAAA;AAAA,IAChB,QAAA,EAAU,OAAA;AAAA,IACV,QAAA,EAAU,OAAA;AAAA,IACV,cAAc,YAAA,CAAa,MAAA;AAAA,IAC3B,eAAA,EAAiB,YAAA,CAAa,SAAA,CAAU,IAAA,CAAK,IAAA,EAAM;AAAA,MACjD,UAAA,EAAY,eAAA;AAAA,MACZ,WAAW,IAAA,CAAK;AAAA,KACjB;AAAA,GACF,CAAA;AAGD,EAAA,MAAM,aAAa,WAAA,EAAY;AAE/B,EAAA,IAAI,iBAAA,EAAmB;AACrB,IAAA,OAAA,CAAQ,EAAA,CAAG,QAAQ,YAAY;AAC7B,MAAAC,mBAAA,CAAG,MAAA,CAAO,aAAA,EAAe,EAAE,CAAA;AAAA,IAC7B,CAAC,CAAA;AAAA,EACH;AACF;;"}
|
|
@@ -11,8 +11,9 @@ var utility = require('../../lib/utility.cjs.js');
|
|
|
11
11
|
var pluginTechdocsNode = require('@backstage/plugin-techdocs-node');
|
|
12
12
|
var fs = require('fs-extra');
|
|
13
13
|
var utils = require('./utils.cjs.js');
|
|
14
|
-
var
|
|
14
|
+
var registry = require('../../lib/engines/registry.cjs.js');
|
|
15
15
|
var catalogEntity = require('../../lib/catalogEntity.cjs.js');
|
|
16
|
+
var prepareServeConfig = require('../../lib/prepareServeConfig.cjs.js');
|
|
16
17
|
|
|
17
18
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
18
19
|
|
|
@@ -40,15 +41,15 @@ async function serve(opts) {
|
|
|
40
41
|
opts.engine,
|
|
41
42
|
logger
|
|
42
43
|
);
|
|
43
|
-
const engineConfig
|
|
44
|
+
const engineConfig = registry.getEngineConfig(engine, engineSource);
|
|
44
45
|
const isDevMode = Object.keys(process.env).includes("TECHDOCS_CLI_DEV_MODE") ? true : false;
|
|
45
46
|
const backstageBackendPort = 7007;
|
|
46
|
-
const enginePort =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
47
|
+
const enginePort = utils.resolveDeprecatedOption(logger, {
|
|
48
|
+
value: opts.enginePort,
|
|
49
|
+
flag: "--engine-port",
|
|
50
|
+
deprecatedValue: opts.mkdocsPort,
|
|
51
|
+
deprecatedFlag: "--mkdocs-port"
|
|
52
|
+
}) ?? "8000";
|
|
52
53
|
for (const flag of ["Clean", "Dirtyreload", "Strict"]) {
|
|
53
54
|
if (opts[`mkdocsParameter${flag}`]) {
|
|
54
55
|
logger.warn(
|
|
@@ -59,17 +60,22 @@ async function serve(opts) {
|
|
|
59
60
|
const engineDockerAddr = `http://0.0.0.0:${enginePort}`;
|
|
60
61
|
const engineLocalAddr = `http://127.0.0.1:${enginePort}`;
|
|
61
62
|
const engineExpectedDevAddr = opts.docker ? engineDockerAddr : engineLocalAddr;
|
|
62
|
-
const configFileName =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
63
|
+
const configFileName = utils.resolveDeprecatedOption(logger, {
|
|
64
|
+
value: opts.configFileName,
|
|
65
|
+
flag: "--config-file-name",
|
|
66
|
+
deprecatedValue: opts.mkdocsConfigFileName,
|
|
67
|
+
deprecatedFlag: "--mkdocs-config-file-name"
|
|
68
|
+
});
|
|
68
69
|
const siteName = opts.siteName;
|
|
69
70
|
const { path: mkdocsYmlPath, configIsTemporary } = await pluginTechdocsNode.getMkdocsYml("./", {
|
|
70
71
|
name: siteName,
|
|
71
72
|
mkdocsConfigFileName: configFileName
|
|
72
73
|
});
|
|
74
|
+
const serveConfigPath = await prepareServeConfig.prepareServeConfig(
|
|
75
|
+
engineConfig,
|
|
76
|
+
mkdocsYmlPath,
|
|
77
|
+
logger
|
|
78
|
+
);
|
|
73
79
|
if (opts.docker) {
|
|
74
80
|
const isDockerOperational = await utils.checkIfDockerIsOperational(logger);
|
|
75
81
|
if (!isDockerOperational) {
|
|
@@ -85,7 +91,7 @@ async function serve(opts) {
|
|
|
85
91
|
return;
|
|
86
92
|
}
|
|
87
93
|
logger.verbose(`${logPrefix} ${line}`);
|
|
88
|
-
if (!docsServerHasStarted &&
|
|
94
|
+
if (!docsServerHasStarted && engineConfig.startupLogPattern.test(line)) {
|
|
89
95
|
docsServerHasStarted = true;
|
|
90
96
|
}
|
|
91
97
|
});
|
|
@@ -93,15 +99,15 @@ async function serve(opts) {
|
|
|
93
99
|
logger.info(`Starting ${engine} server.`);
|
|
94
100
|
const docsChildProcess = server.runEngineServer({
|
|
95
101
|
port: enginePort,
|
|
96
|
-
dockerImage: opts.dockerImage,
|
|
102
|
+
dockerImage: opts.dockerImage ?? engineConfig.defaultImage,
|
|
97
103
|
dockerEntrypoint: opts.dockerEntrypoint,
|
|
98
104
|
dockerOptions: opts.dockerOption,
|
|
99
105
|
useDocker: opts.docker,
|
|
100
106
|
onStdout: docsLogFunc,
|
|
101
107
|
onStderr: docsLogFunc,
|
|
102
|
-
engineBinary: engineConfig
|
|
103
|
-
engineServeArgs: engineConfig
|
|
104
|
-
configFile:
|
|
108
|
+
engineBinary: engineConfig.binary,
|
|
109
|
+
engineServeArgs: engineConfig.serveArgs(enginePort, {
|
|
110
|
+
configFile: serveConfigPath,
|
|
105
111
|
clean: opts.parameterClean || opts.mkdocsParameterClean,
|
|
106
112
|
dirtyReload: opts.parameterDirtyreload || opts.mkdocsParameterDirtyreload,
|
|
107
113
|
strict: opts.parameterStrict || opts.mkdocsParameterStrict,
|
|
@@ -127,7 +133,7 @@ async function serve(opts) {
|
|
|
127
133
|
port,
|
|
128
134
|
engineExpectedDevAddr,
|
|
129
135
|
opts.verbose,
|
|
130
|
-
engineConfig
|
|
136
|
+
engineConfig
|
|
131
137
|
);
|
|
132
138
|
httpServer$1.serve().catch((err) => {
|
|
133
139
|
logger.error("Failed to start HTTP server", err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.cjs.js","sources":["../../../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 { OptionValues } from 'commander';\nimport path from 'node:path';\nimport openBrowser from 'react-dev-utils/openBrowser';\nimport { findOwnPaths, RunOnOutput } from '@backstage/cli-common';\nimport HTTPServer from '../../lib/httpServer';\nimport { runEngineServer } from '../../lib/server';\nimport { createLogger } from '../../lib/utility';\nimport { getMkdocsYml } from '@backstage/plugin-techdocs-node';\nimport fs from 'fs-extra';\nimport { checkIfDockerIsOperational } from './utils';\nimport { getEngineConfig } from '../../lib/engineConfig';\nimport { resolveEngine } from '../../lib/catalogEntity';\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 findOwnPaths(__dirname).resolve('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 const { engine, source: engineSource } = await resolveEngine(\n process.cwd(),\n opts.engine,\n logger,\n );\n const engineConfig = getEngineConfig(engine, engineSource);\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 enginePort = opts.enginePort ?? opts.mkdocsPort ?? '8000';\n if (opts.mkdocsPort && !opts.enginePort) {\n logger.warn(\n '--mkdocs-port is deprecated and will be removed in a future release. Use --engine-port instead.',\n );\n }\n for (const flag of ['Clean', 'Dirtyreload', 'Strict']) {\n if (opts[`mkdocsParameter${flag}`]) {\n logger.warn(\n `--mkdocs-parameter-${flag.toLowerCase()} is deprecated and will be removed in a future release. Use --parameter-${flag.toLowerCase()} instead.`,\n );\n }\n }\n\n const engineDockerAddr = `http://0.0.0.0:${enginePort}`;\n const engineLocalAddr = `http://127.0.0.1:${enginePort}`;\n const engineExpectedDevAddr = opts.docker\n ? engineDockerAddr\n : engineLocalAddr;\n\n const configFileName = opts.configFileName ?? opts.mkdocsConfigFileName;\n if (opts.mkdocsConfigFileName && !opts.configFileName) {\n logger.warn(\n '--mkdocs-config-file-name is deprecated and will be removed in a future release. Use --config-file-name instead.',\n );\n }\n const siteName = opts.siteName;\n\n const { path: mkdocsYmlPath, configIsTemporary } = await getMkdocsYml('./', {\n name: siteName,\n mkdocsConfigFileName: configFileName,\n });\n\n // Validate that Docker is up and running\n if (opts.docker) {\n const isDockerOperational = await checkIfDockerIsOperational(logger);\n if (!isDockerOperational) {\n return;\n }\n }\n\n let docsServerHasStarted = false;\n const docsLogFunc: RunOnOutput = data => {\n const logLines = data.toString().split('\\n');\n const logPrefix = opts.docker ? `[docker/${engine}]` : `[${engine}]`;\n logLines.forEach(line => {\n if (line === '') {\n return;\n }\n\n logger.verbose(`${logPrefix} ${line}`);\n\n if (\n !docsServerHasStarted &&\n line.includes(`${engineConfig.startupLogPattern}`)\n ) {\n docsServerHasStarted = true;\n }\n });\n };\n logger.info(`Starting ${engine} server.`);\n const docsChildProcess = runEngineServer({\n port: enginePort,\n dockerImage: opts.dockerImage,\n dockerEntrypoint: opts.dockerEntrypoint,\n dockerOptions: opts.dockerOption,\n useDocker: opts.docker,\n onStdout: docsLogFunc,\n onStderr: docsLogFunc,\n engineBinary: engineConfig.binary,\n engineServeArgs: engineConfig.serveArgs(enginePort, {\n configFile: mkdocsYmlPath,\n clean: opts.parameterClean || opts.mkdocsParameterClean,\n dirtyReload: opts.parameterDirtyreload || opts.mkdocsParameterDirtyreload,\n strict: opts.parameterStrict || opts.mkdocsParameterStrict,\n useDocker: opts.docker,\n }),\n });\n\n for (let attempt = 0; attempt < 30; attempt++) {\n await new Promise(r => setTimeout(r, 3000));\n if (docsServerHasStarted) {\n break;\n }\n logger.info(`Waiting for ${engine} server to start...`);\n }\n\n if (!docsServerHasStarted) {\n logger.error(\n `${engine} 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 engineExpectedDevAddr,\n opts.verbose,\n engineConfig,\n );\n\n httpServer\n .serve()\n .catch(err => {\n logger.error('Failed to start HTTP server', err);\n docsChildProcess.kill();\n process.exit(1);\n })\n .then(() => {\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 docsChildProcess.waitForExit();\n\n if (configIsTemporary) {\n process.on('exit', async () => {\n fs.rmSync(mkdocsYmlPath, {});\n });\n }\n}\n"],"names":["path","findOwnPaths","createLogger","resolveEngine","engineConfig","getEngineConfig","getMkdocsYml","checkIfDockerIsOperational","runEngineServer","httpServer","HTTPServer","openBrowser","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAS,qBAAA,GAAgC;AACvC,EAAA,IAAI;AACF,IAAA,OAAOA,qBAAA,CAAK,IAAA;AAAA,MACVA,qBAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAQ,wCAAwC,CAAC,CAAA;AAAA,MACtE;AAAA,KACF;AAAA,EACF,CAAA,CAAA,MAAQ;AASN,IAAA,OAAOC,sBAAA,CAAa,SAAS,CAAA,CAAE,OAAA,CAAQ,mBAAmB,CAAA;AAAA,EAC5D;AACF;AAEA,SAAS,kBAAkB,IAAA,EAA4B;AACrD,EAAA,OAAO,IAAA,CAAK,wBAAwB,qBAAA,EAAsB;AAC5D;AAEA,eAA8B,MAAM,IAAA,EAAoB;AACtD,EAAA,MAAM,SAASC,oBAAA,CAAa,EAAE,OAAA,EAAS,IAAA,CAAK,SAAS,CAAA;AAErD,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,YAAA,KAAiB,MAAMC,2BAAA;AAAA,IAC7C,QAAQ,GAAA,EAAI;AAAA,IACZ,IAAA,CAAK,MAAA;AAAA,IACL;AAAA,GACF;AACA,EAAA,MAAMC,cAAA,GAAeC,4BAAA,CAAgB,MAAA,EAAQ,YAAY,CAAA;AAKzD,EAAA,MAAM,SAAA,GAAY,OAAO,IAAA,CAAK,OAAA,CAAQ,GAAG,CAAA,CAAE,QAAA,CAAS,uBAAuB,CAAA,GACvE,IAAA,GACA,KAAA;AAEJ,EAAA,MAAM,oBAAA,GAAuB,IAAA;AAE7B,EAAA,MAAM,UAAA,GAAa,IAAA,CAAK,UAAA,IAAc,IAAA,CAAK,UAAA,IAAc,MAAA;AACzD,EAAA,IAAI,IAAA,CAAK,UAAA,IAAc,CAAC,IAAA,CAAK,UAA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AAA,CAAO,IAAA;AAAA,MACL,iDAAiD,IAAI,CAAA;AAAA,gBAAA;AAAA,KACvD;AAAA,EACF,CAAC,CAAA;AAEH,EAAA,MAAM,iBAAiB,WAAA,EAAY;AAEnC,EAAA,IAAI,iBAAA,EAAmB;AACrB,IAAA,OAAA,CAAQ,EAAA,CAAG,QAAQ,YAAY;AAC7B,MAAAC,mBAAA,CAAG,MAAA,CAAO,aAAA,EAAe,EAAE,CAAA;AAAA,IAC7B,CAAC,CAAA;AAAA,EACH;AACF;;"}
|
|
1
|
+
{"version":3,"file":"serve.cjs.js","sources":["../../../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 { OptionValues } from 'commander';\nimport path from 'node:path';\nimport openBrowser from 'react-dev-utils/openBrowser';\nimport { findOwnPaths, RunOnOutput } from '@backstage/cli-common';\nimport HTTPServer from '../../lib/httpServer';\nimport { runEngineServer } from '../../lib/server';\nimport { createLogger } from '../../lib/utility';\nimport { getMkdocsYml } from '@backstage/plugin-techdocs-node';\nimport fs from 'fs-extra';\nimport { checkIfDockerIsOperational, resolveDeprecatedOption } from './utils';\nimport { getEngineConfig } from '../../lib/engines';\nimport { resolveEngine } from '../../lib/catalogEntity';\nimport { prepareServeConfig } from '../../lib/prepareServeConfig';\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 findOwnPaths(__dirname).resolve('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 const { engine, source: engineSource } = await resolveEngine(\n process.cwd(),\n opts.engine,\n logger,\n );\n const engineConfig = getEngineConfig(engine, engineSource);\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 enginePort =\n resolveDeprecatedOption(logger, {\n value: opts.enginePort,\n flag: '--engine-port',\n deprecatedValue: opts.mkdocsPort,\n deprecatedFlag: '--mkdocs-port',\n }) ?? '8000';\n for (const flag of ['Clean', 'Dirtyreload', 'Strict']) {\n if (opts[`mkdocsParameter${flag}`]) {\n logger.warn(\n `--mkdocs-parameter-${flag.toLowerCase()} is deprecated and will be removed in a future release. Use --parameter-${flag.toLowerCase()} instead.`,\n );\n }\n }\n\n const engineDockerAddr = `http://0.0.0.0:${enginePort}`;\n const engineLocalAddr = `http://127.0.0.1:${enginePort}`;\n const engineExpectedDevAddr = opts.docker\n ? engineDockerAddr\n : engineLocalAddr;\n\n const configFileName = resolveDeprecatedOption(logger, {\n value: opts.configFileName,\n flag: '--config-file-name',\n deprecatedValue: opts.mkdocsConfigFileName,\n deprecatedFlag: '--mkdocs-config-file-name',\n });\n const siteName = opts.siteName;\n\n const { path: mkdocsYmlPath, configIsTemporary } = await getMkdocsYml('./', {\n name: siteName,\n mkdocsConfigFileName: configFileName,\n });\n\n const serveConfigPath = await prepareServeConfig(\n engineConfig,\n mkdocsYmlPath,\n logger,\n );\n\n // Validate that Docker is up and running\n if (opts.docker) {\n const isDockerOperational = await checkIfDockerIsOperational(logger);\n if (!isDockerOperational) {\n return;\n }\n }\n\n let docsServerHasStarted = false;\n const docsLogFunc: RunOnOutput = data => {\n const logLines = data.toString().split('\\n');\n const logPrefix = opts.docker ? `[docker/${engine}]` : `[${engine}]`;\n logLines.forEach(line => {\n if (line === '') {\n return;\n }\n\n logger.verbose(`${logPrefix} ${line}`);\n\n if (!docsServerHasStarted && engineConfig.startupLogPattern.test(line)) {\n docsServerHasStarted = true;\n }\n });\n };\n logger.info(`Starting ${engine} server.`);\n const docsChildProcess = runEngineServer({\n port: enginePort,\n dockerImage: opts.dockerImage ?? engineConfig.defaultImage,\n dockerEntrypoint: opts.dockerEntrypoint,\n dockerOptions: opts.dockerOption,\n useDocker: opts.docker,\n onStdout: docsLogFunc,\n onStderr: docsLogFunc,\n engineBinary: engineConfig.binary,\n engineServeArgs: engineConfig.serveArgs(enginePort, {\n configFile: serveConfigPath,\n clean: opts.parameterClean || opts.mkdocsParameterClean,\n dirtyReload: opts.parameterDirtyreload || opts.mkdocsParameterDirtyreload,\n strict: opts.parameterStrict || opts.mkdocsParameterStrict,\n useDocker: opts.docker,\n }),\n });\n\n for (let attempt = 0; attempt < 30; attempt++) {\n await new Promise(r => setTimeout(r, 3000));\n if (docsServerHasStarted) {\n break;\n }\n logger.info(`Waiting for ${engine} server to start...`);\n }\n\n if (!docsServerHasStarted) {\n logger.error(\n `${engine} 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 engineExpectedDevAddr,\n opts.verbose,\n engineConfig,\n );\n\n httpServer\n .serve()\n .catch(err => {\n logger.error('Failed to start HTTP server', err);\n docsChildProcess.kill();\n process.exit(1);\n })\n .then(() => {\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 docsChildProcess.waitForExit();\n\n if (configIsTemporary) {\n process.on('exit', async () => {\n fs.rmSync(mkdocsYmlPath, {});\n });\n }\n}\n"],"names":["path","findOwnPaths","createLogger","resolveEngine","getEngineConfig","resolveDeprecatedOption","getMkdocsYml","prepareServeConfig","checkIfDockerIsOperational","runEngineServer","httpServer","HTTPServer","openBrowser","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAS,qBAAA,GAAgC;AACvC,EAAA,IAAI;AACF,IAAA,OAAOA,qBAAA,CAAK,IAAA;AAAA,MACVA,qBAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAQ,wCAAwC,CAAC,CAAA;AAAA,MACtE;AAAA,KACF;AAAA,EACF,CAAA,CAAA,MAAQ;AASN,IAAA,OAAOC,sBAAA,CAAa,SAAS,CAAA,CAAE,OAAA,CAAQ,mBAAmB,CAAA;AAAA,EAC5D;AACF;AAEA,SAAS,kBAAkB,IAAA,EAA4B;AACrD,EAAA,OAAO,IAAA,CAAK,wBAAwB,qBAAA,EAAsB;AAC5D;AAEA,eAA8B,MAAM,IAAA,EAAoB;AACtD,EAAA,MAAM,SAASC,oBAAA,CAAa,EAAE,OAAA,EAAS,IAAA,CAAK,SAAS,CAAA;AAErD,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,YAAA,KAAiB,MAAMC,2BAAA;AAAA,IAC7C,QAAQ,GAAA,EAAI;AAAA,IACZ,IAAA,CAAK,MAAA;AAAA,IACL;AAAA,GACF;AACA,EAAA,MAAM,YAAA,GAAeC,wBAAA,CAAgB,MAAA,EAAQ,YAAY,CAAA;AAKzD,EAAA,MAAM,SAAA,GAAY,OAAO,IAAA,CAAK,OAAA,CAAQ,GAAG,CAAA,CAAE,QAAA,CAAS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