@techdocs/cli 1.3.2-next.2 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/cjs/{generate-103520bb.cjs.js → generate-2111f828.cjs.js} +11 -2
- package/dist/cjs/generate-2111f828.cjs.js.map +1 -0
- package/dist/cjs/{mkdocs-1501e940.cjs.js → mkdocs-452eb543.cjs.js} +13 -1
- package/dist/cjs/mkdocs-452eb543.cjs.js.map +1 -0
- package/dist/cjs/{serve-ca27a9de.cjs.js → serve-5138af76.cjs.js} +17 -5
- package/dist/cjs/serve-5138af76.cjs.js.map +1 -0
- package/dist/embedded-app/index.html +1 -1
- package/dist/embedded-app/static/{5837.51740a39.chunk.js → 5837.239cccbd.chunk.js} +1 -1
- package/dist/embedded-app/static/{5837.51740a39.chunk.js.map → 5837.239cccbd.chunk.js.map} +1 -1
- package/dist/embedded-app/static/{6051.e3b445b2.chunk.js → 6051.66d9ff08.chunk.js} +1 -1
- package/dist/embedded-app/static/{6051.e3b445b2.chunk.js.map → 6051.66d9ff08.chunk.js.map} +1 -1
- package/dist/embedded-app/static/{7560.ecd330c0.chunk.js → 7560.3487acce.chunk.js} +1 -1
- package/dist/embedded-app/static/{7560.ecd330c0.chunk.js.map → 7560.3487acce.chunk.js.map} +1 -1
- package/dist/embedded-app/static/7670.5e26cab8.chunk.js +3 -0
- package/dist/embedded-app/static/7670.5e26cab8.chunk.js.map +1 -0
- package/dist/embedded-app/static/{7750.0502b5b8.chunk.js → 7750.6d01f7cb.chunk.js} +1 -1
- package/dist/embedded-app/static/{7750.0502b5b8.chunk.js.map → 7750.6d01f7cb.chunk.js.map} +1 -1
- package/dist/embedded-app/static/{8951.3e2e38b8.chunk.js → 8951.fbe78c62.chunk.js} +1 -1
- package/dist/embedded-app/static/{8951.3e2e38b8.chunk.js.map → 8951.fbe78c62.chunk.js.map} +1 -1
- package/dist/embedded-app/static/main.a942e8cf.js +503 -0
- package/dist/embedded-app/static/main.a942e8cf.js.map +1 -0
- package/dist/embedded-app/static/{runtime.abaaf437.js → runtime.a942e8cf.js} +2 -2
- package/dist/embedded-app/static/{runtime.abaaf437.js.map → runtime.a942e8cf.js.map} +1 -1
- package/dist/embedded-app/static/{vendor.abaaf437.js → vendor.a942e8cf.js} +1 -1
- package/dist/embedded-app/static/{vendor.abaaf437.js.map → vendor.a942e8cf.js.map} +1 -1
- package/dist/index.cjs.js +16 -4
- package/dist/index.cjs.js.map +1 -1
- package/package.json +5 -5
- package/dist/cjs/generate-103520bb.cjs.js.map +0 -1
- package/dist/cjs/mkdocs-1501e940.cjs.js.map +0 -1
- package/dist/cjs/serve-ca27a9de.cjs.js.map +0 -1
- package/dist/embedded-app/static/7670.3857b377.chunk.js +0 -3
- package/dist/embedded-app/static/7670.3857b377.chunk.js.map +0 -1
- package/dist/embedded-app/static/main.abaaf437.js +0 -503
- package/dist/embedded-app/static/main.abaaf437.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @techdocs/cli
|
|
2
2
|
|
|
3
|
+
## 1.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- dd1e37649f: Deprecated getMkDocsYml in favor of getMkdocsYml (lowercase 'd')
|
|
8
|
+
- dcacf94912: Fix proxying to mkdocs
|
|
9
|
+
|
|
10
|
+
The domain localhost may point to both 127.0.0.1 and ::1, ipv4 and ipv6
|
|
11
|
+
and when node tries to lookup localhost it might prefer ipv6 while mkdocs
|
|
12
|
+
is only listening on ipv4. This tells node-proxy to target the ipv4 address
|
|
13
|
+
instead of relying on localhost hostname lookup.
|
|
14
|
+
|
|
15
|
+
- 339d9a5b5c: Added support for using a default `mkdocs.yml` configuration file when none is provided
|
|
16
|
+
- 6e0b6a0d50: Fixed publish command missing awsBucketRootPath option.
|
|
17
|
+
Fixed publish command having the gcsBucketRootPath option misconfigured, previously returning a boolean vs a string.
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @backstage/backend-common@0.18.2
|
|
20
|
+
- @backstage/plugin-techdocs-node@1.5.0
|
|
21
|
+
- @backstage/catalog-model@1.2.0
|
|
22
|
+
- @backstage/cli-common@0.1.11
|
|
23
|
+
- @backstage/config@1.0.6
|
|
24
|
+
|
|
3
25
|
## 1.3.2-next.2
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -27,6 +27,9 @@ async function generate(opts) {
|
|
|
27
27
|
logger.info(`Will output generated files in ${outputDir}`);
|
|
28
28
|
logger.verbose("Creating output directory if it does not exist.");
|
|
29
29
|
await fs__default["default"].ensureDir(outputDir);
|
|
30
|
+
const { path: mkdocsYmlPath, configIsTemporary } = await pluginTechdocsNode.getMkdocsYml(
|
|
31
|
+
sourceDir
|
|
32
|
+
);
|
|
30
33
|
const config$1 = new config.ConfigReader({
|
|
31
34
|
techdocs: {
|
|
32
35
|
generator: {
|
|
@@ -68,10 +71,16 @@ async function generate(opts) {
|
|
|
68
71
|
} : {},
|
|
69
72
|
logger,
|
|
70
73
|
etag: opts.etag,
|
|
71
|
-
...process.env.LOG_LEVEL === "debug" ? { logStream: process$1.stdout } : {}
|
|
74
|
+
...process.env.LOG_LEVEL === "debug" ? { logStream: process$1.stdout } : {},
|
|
75
|
+
siteOptions: { name: opts.siteName }
|
|
72
76
|
});
|
|
77
|
+
if (configIsTemporary) {
|
|
78
|
+
process.on("exit", async () => {
|
|
79
|
+
fs__default["default"].rmSync(mkdocsYmlPath, {});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
73
82
|
logger.info("Done!");
|
|
74
83
|
}
|
|
75
84
|
|
|
76
85
|
exports["default"] = generate;
|
|
77
|
-
//# sourceMappingURL=generate-
|
|
86
|
+
//# sourceMappingURL=generate-2111f828.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-2111f828.cjs.js","sources":["../../src/commands/generate/generate.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { resolve } from 'path';\nimport { OptionValues } from 'commander';\nimport fs from 'fs-extra';\nimport Docker from 'dockerode';\nimport {\n TechdocsGenerator,\n ParsedLocationAnnotation,\n getMkdocsYml,\n} from '@backstage/plugin-techdocs-node';\nimport {\n ContainerRunner,\n DockerContainerRunner,\n} from '@backstage/backend-common';\nimport { ConfigReader } from '@backstage/config';\nimport {\n convertTechDocsRefToLocationAnnotation,\n createLogger,\n} from '../../lib/utility';\nimport { stdout } from 'process';\n\nexport default async function generate(opts: OptionValues) {\n // Use techdocs-node package to generate docs. Keep consistency between Backstage and CI generating docs.\n // Docs can be prepared using actions/checkout or git clone, or similar paradigms on CI. The TechDocs CI workflow\n // will run on the CI pipeline containing the documentation files.\n\n const logger = createLogger({ verbose: opts.verbose });\n\n const sourceDir = resolve(opts.sourceDir);\n const outputDir = resolve(opts.outputDir);\n const omitTechdocsCorePlugin = opts.omitTechdocsCoreMkdocsPlugin;\n const dockerImage = opts.dockerImage;\n const pullImage = opts.pull;\n const legacyCopyReadmeMdToIndexMd = opts.legacyCopyReadmeMdToIndexMd;\n\n logger.info(`Using source dir ${sourceDir}`);\n logger.info(`Will output generated files in ${outputDir}`);\n\n logger.verbose('Creating output directory if it does not exist.');\n\n await fs.ensureDir(outputDir);\n\n const { path: mkdocsYmlPath, configIsTemporary } = await getMkdocsYml(\n sourceDir,\n );\n\n const config = new ConfigReader({\n techdocs: {\n generator: {\n runIn: opts.docker ? 'docker' : 'local',\n dockerImage,\n pullImage,\n mkdocs: {\n legacyCopyReadmeMdToIndexMd,\n omitTechdocsCorePlugin,\n },\n },\n },\n });\n\n // Docker client (conditionally) used by the generators, based on techdocs.generators config.\n let containerRunner: ContainerRunner | undefined;\n\n if (opts.docker) {\n const dockerClient = new Docker();\n containerRunner = new DockerContainerRunner({ dockerClient });\n }\n\n let parsedLocationAnnotation = {} as ParsedLocationAnnotation;\n if (opts.techdocsRef) {\n try {\n parsedLocationAnnotation = convertTechDocsRefToLocationAnnotation(\n opts.techdocsRef,\n );\n } catch (err) {\n logger.error(err.message);\n }\n }\n\n // Generate docs using @backstage/plugin-techdocs-node\n const techdocsGenerator = await TechdocsGenerator.fromConfig(config, {\n logger,\n containerRunner,\n });\n\n logger.info('Generating documentation...');\n\n await techdocsGenerator.run({\n inputDir: sourceDir,\n outputDir,\n ...(opts.techdocsRef\n ? {\n parsedLocationAnnotation,\n }\n : {}),\n logger,\n etag: opts.etag,\n ...(process.env.LOG_LEVEL === 'debug' ? { logStream: stdout } : {}),\n siteOptions: { name: opts.siteName },\n });\n\n if (configIsTemporary) {\n process.on('exit', async () => {\n fs.rmSync(mkdocsYmlPath, {});\n });\n }\n\n logger.info('Done!');\n}\n"],"names":["createLogger","resolve","fs","getMkdocsYml","config","ConfigReader","Docker","DockerContainerRunner","convertTechDocsRefToLocationAnnotation","TechdocsGenerator","stdout"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,eAA8B,SAAS,IAAoB,EAAA;AAKzD,EAAA,MAAM,SAASA,oBAAa,CAAA,EAAE,OAAS,EAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AAErD,EAAM,MAAA,SAAA,GAAYC,YAAQ,CAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AACxC,EAAM,MAAA,SAAA,GAAYA,YAAQ,CAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AACxC,EAAA,MAAM,yBAAyB,IAAK,CAAA,4BAAA,CAAA;AACpC,EAAA,MAAM,cAAc,IAAK,CAAA,WAAA,CAAA;AACzB,EAAA,MAAM,YAAY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AAA;AAAA,KAC1B;AAAA,GACF;AAGA,EAAA,MAAM,iBAAoB,GAAA,MAAMC,oCAAkB,CAAA,UAAA,CAAWL,QAAQ,EAAA;AAAA,IACnE,MAAA;AAAA,IACA,eAAA;AAAA,GACD,CAAA,CAAA;AAED,EAAA,MAAA,CAAO,KAAK,6BAA6B,CAAA,CAAA;AAEzC,EAAA,MAAM,kBAAkB,GAAI,CAAA;AAAA,IAC1B,QAAU,EAAA,SAAA;AAAA,IACV,SAAA;AAAA,IACA,GAAI,KAAK,WACL,GAAA;AAAA,MACE,wBAAA;AAAA,QAEF,EAAC;AAAA,IACL,MAAA;AAAA,IACA,MAAM,IAAK,CAAA,IAAA;AAAA,IACX,GAAI,QAAQ,GAAI,CAAA,SAAA,KAAc,UAAU,EAAE,SAAA,EAAWM,gBAAO,EAAA,GAAI,EAAC;AAAA,IACjE,WAAa,EAAA,EAAE,IAAM,EAAA,IAAA,CAAK,QAAS,EAAA;AAAA,GACpC,CAAA,CAAA;AAED,EAAA,IAAI,iBAAmB,EAAA;AACrB,IAAQ,OAAA,CAAA,EAAA,CAAG,QAAQ,YAAY;AAC7B,MAAGR,sBAAA,CAAA,MAAA,CAAO,aAAe,EAAA,EAAE,CAAA,CAAA;AAAA,KAC5B,CAAA,CAAA;AAAA,GACH;AAEA,EAAA,MAAA,CAAO,KAAK,OAAO,CAAA,CAAA;AACrB;;;;"}
|
|
@@ -3,18 +3,25 @@
|
|
|
3
3
|
var openBrowser = require('react-dev-utils/openBrowser');
|
|
4
4
|
var utility = require('./utility-647ad232.cjs.js');
|
|
5
5
|
var mkdocsServer = require('./mkdocsServer-99ec8af2.cjs.js');
|
|
6
|
+
var pluginTechdocsNode = require('@backstage/plugin-techdocs-node');
|
|
7
|
+
var fs = require('fs-extra');
|
|
6
8
|
require('winston');
|
|
7
9
|
require('child_process');
|
|
8
10
|
|
|
9
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
12
|
|
|
11
13
|
var openBrowser__default = /*#__PURE__*/_interopDefaultLegacy(openBrowser);
|
|
14
|
+
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
12
15
|
|
|
13
16
|
async function serveMkdocs(opts) {
|
|
14
17
|
const logger = utility.createLogger({ verbose: opts.verbose });
|
|
15
18
|
const dockerAddr = `http://0.0.0.0:${opts.port}`;
|
|
16
19
|
const localAddr = `http://127.0.0.1:${opts.port}`;
|
|
17
20
|
const expectedDevAddr = opts.docker ? dockerAddr : localAddr;
|
|
21
|
+
const { path: mkdocsYmlPath, configIsTemporary } = await pluginTechdocsNode.getMkdocsYml(
|
|
22
|
+
"./",
|
|
23
|
+
opts.siteName
|
|
24
|
+
);
|
|
18
25
|
let boolOpenBrowserTriggered = false;
|
|
19
26
|
const logFunc = (data) => {
|
|
20
27
|
const logLines = data.toString().split("\n");
|
|
@@ -43,7 +50,12 @@ Starting mkdocs server on ${localAddr}
|
|
|
43
50
|
stderrLogFunc: logFunc
|
|
44
51
|
});
|
|
45
52
|
await mkdocsServer.waitForSignal([childProcess]);
|
|
53
|
+
if (configIsTemporary) {
|
|
54
|
+
process.on("exit", async () => {
|
|
55
|
+
fs__default["default"].rmSync(mkdocsYmlPath, {});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
46
58
|
}
|
|
47
59
|
|
|
48
60
|
exports["default"] = serveMkdocs;
|
|
49
|
-
//# sourceMappingURL=mkdocs-
|
|
61
|
+
//# sourceMappingURL=mkdocs-452eb543.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mkdocs-452eb543.cjs.js","sources":["../../src/commands/serve/mkdocs.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { OptionValues } from 'commander';\nimport openBrowser from 'react-dev-utils/openBrowser';\nimport { createLogger } from '../../lib/utility';\nimport { runMkdocsServer } from '../../lib/mkdocsServer';\nimport { LogFunc, waitForSignal } from '../../lib/run';\nimport { getMkdocsYml } from '@backstage/plugin-techdocs-node';\nimport fs from 'fs-extra';\n\nexport default async function serveMkdocs(opts: OptionValues) {\n const logger = createLogger({ verbose: opts.verbose });\n\n const dockerAddr = `http://0.0.0.0:${opts.port}`;\n const localAddr = `http://127.0.0.1:${opts.port}`;\n const expectedDevAddr = opts.docker ? dockerAddr : localAddr;\n\n const { path: mkdocsYmlPath, configIsTemporary } = await getMkdocsYml(\n './',\n opts.siteName,\n );\n\n // We want to open browser only once based on a log.\n let boolOpenBrowserTriggered = false;\n\n const logFunc: LogFunc = data => {\n // Sometimes the lines contain an unnecessary extra new line in between\n const logLines = data.toString().split('\\n');\n const logPrefix = opts.docker ? '[docker/mkdocs]' : '[mkdocs]';\n logLines.forEach(line => {\n if (line === '') {\n return;\n }\n\n // Logs from container is verbose.\n logger.verbose(`${logPrefix} ${line}`);\n\n // When the server has started, open a new browser tab for the user.\n if (\n !boolOpenBrowserTriggered &&\n line.includes(`Serving on ${expectedDevAddr}`)\n ) {\n // Always open the local address, since 0.0.0.0 belongs to docker\n logger.info(`\\nStarting mkdocs server on ${localAddr}\\n`);\n openBrowser(localAddr);\n boolOpenBrowserTriggered = true;\n }\n });\n };\n // mkdocs writes all of its logs to stderr by default, and not stdout.\n // https://github.com/mkdocs/mkdocs/issues/879#issuecomment-203536006\n // Had me questioning this whole implementation for half an hour.\n\n // Commander stores --no-docker in cmd.docker variable\n const childProcess = await runMkdocsServer({\n port: opts.port,\n dockerImage: opts.dockerImage,\n dockerEntrypoint: opts.dockerEntrypoint,\n dockerOptions: opts.dockerOption,\n useDocker: opts.docker,\n stdoutLogFunc: logFunc,\n stderrLogFunc: logFunc,\n });\n\n // Keep waiting for user to cancel the process\n await waitForSignal([childProcess]);\n\n if (configIsTemporary) {\n process.on('exit', async () => {\n fs.rmSync(mkdocsYmlPath, {});\n });\n }\n}\n"],"names":["createLogger","getMkdocsYml","openBrowser","runMkdocsServer","waitForSignal","fs"],"mappings":";;;;;;;;;;;;;;;AAwBA,eAA8B,YAAY,IAAoB,EAAA;AAC5D,EAAA,MAAM,SAASA,oBAAa,CAAA,EAAE,OAAS,EAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AAErD,EAAM,MAAA,UAAA,GAAa,kBAAkB,IAAK,CAAA,IAAA,CAAA,CAAA,CAAA;AAC1C,EAAM,MAAA,SAAA,GAAY,oBAAoB,IAAK,CAAA,IAAA,CAAA,CAAA,CAAA;AAC3C,EAAM,MAAA,eAAA,GAAkB,IAAK,CAAA,MAAA,GAAS,UAAa,GAAA,SAAA,CAAA;AAEnD,EAAA,MAAM,EAAE,IAAA,EAAM,aAAe,EAAA,iBAAA,KAAsB,MAAMC,+BAAA;AAAA,IACvD,IAAA;AAAA,IACA,IAAK,CAAA,QAAA;AAAA,GACP,CAAA;AAGA,EAAA,IAAI,wBAA2B,GAAA,KAAA,CAAA;AAE/B,EAAA,MAAM,UAAmB,CAAQ,IAAA,KAAA;AAE/B,IAAA,MAAM,QAAW,GAAA,IAAA,CAAK,QAAS,EAAA,CAAE,MAAM,IAAI,CAAA,CAAA;AAC3C,IAAM,MAAA,SAAA,GAAY,IAAK,CAAA,MAAA,GAAS,iBAAoB,GAAA,UAAA,CAAA;AACpD,IAAA,QAAA,CAAS,QAAQ,CAAQ,IAAA,KAAA;AACvB,MAAA,IAAI,SAAS,EAAI,EAAA;AACf,QAAA,OAAA;AAAA,OACF;AAGA,MAAO,MAAA,CAAA,OAAA,CAAQ,CAAG,EAAA,SAAA,CAAA,CAAA,EAAa,IAAM,CAAA,CAAA,CAAA,CAAA;AAGrC,MAAA,IACE,CAAC,wBACD,IAAA,IAAA,CAAK,QAAS,CAAA,CAAA,WAAA,EAAc,iBAAiB,CAC7C,EAAA;AAEA,QAAA,MAAA,CAAO,IAAK,CAAA,CAAA;AAAA,0BAA+B,EAAA,SAAA,CAAA;AAAA,CAAa,CAAA,CAAA;AACxD,QAAAC,+BAAA,CAAY,SAAS,CAAA,CAAA;AACrB,QAA2B,wBAAA,GAAA,IAAA,CAAA;AAAA,OAC7B;AAAA,KACD,CAAA,CAAA;AAAA,GACH,CAAA;AAMA,EAAM,MAAA,YAAA,GAAe,MAAMC,4BAAgB,CAAA;AAAA,IACzC,MAAM,IAAK,CAAA,IAAA;AAAA,IACX,aAAa,IAAK,CAAA,WAAA;AAAA,IAClB,kBAAkB,IAAK,CAAA,gBAAA;AAAA,IACvB,eAAe,IAAK,CAAA,YAAA;AAAA,IACpB,WAAW,IAAK,CAAA,MAAA;AAAA,IAChB,aAAe,EAAA,OAAA;AAAA,IACf,aAAe,EAAA,OAAA;AAAA,GAChB,CAAA,CAAA;AAGD,EAAM,MAAAC,0BAAA,CAAc,CAAC,YAAY,CAAC,CAAA,CAAA;AAElC,EAAA,IAAI,iBAAmB,EAAA;AACrB,IAAQ,OAAA,CAAA,EAAA,CAAG,QAAQ,YAAY;AAC7B,MAAGC,sBAAA,CAAA,MAAA,CAAO,aAAe,EAAA,EAAE,CAAA,CAAA;AAAA,KAC5B,CAAA,CAAA;AAAA,GACH;AACF;;;;"}
|
|
@@ -8,6 +8,8 @@ var http = require('http');
|
|
|
8
8
|
var httpProxy = require('http-proxy');
|
|
9
9
|
var utility = require('./utility-647ad232.cjs.js');
|
|
10
10
|
var mkdocsServer = require('./mkdocsServer-99ec8af2.cjs.js');
|
|
11
|
+
var pluginTechdocsNode = require('@backstage/plugin-techdocs-node');
|
|
12
|
+
var fs = require('fs-extra');
|
|
11
13
|
require('winston');
|
|
12
14
|
require('child_process');
|
|
13
15
|
|
|
@@ -18,19 +20,20 @@ var openBrowser__default = /*#__PURE__*/_interopDefaultLegacy(openBrowser);
|
|
|
18
20
|
var serveHandler__default = /*#__PURE__*/_interopDefaultLegacy(serveHandler);
|
|
19
21
|
var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
|
|
20
22
|
var httpProxy__default = /*#__PURE__*/_interopDefaultLegacy(httpProxy);
|
|
23
|
+
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
21
24
|
|
|
22
25
|
class HTTPServer {
|
|
23
|
-
constructor(backstageBundleDir, backstagePort,
|
|
26
|
+
constructor(backstageBundleDir, backstagePort, mkdocsTargetAddress, verbose) {
|
|
24
27
|
this.proxyEndpoint = "/api/techdocs/";
|
|
25
28
|
this.backstageBundleDir = backstageBundleDir;
|
|
26
29
|
this.backstagePort = backstagePort;
|
|
27
|
-
this.
|
|
30
|
+
this.mkdocsTargetAddress = mkdocsTargetAddress;
|
|
28
31
|
this.verbose = verbose;
|
|
29
32
|
}
|
|
30
33
|
// Create a Proxy for mkdocs server
|
|
31
34
|
createProxy() {
|
|
32
35
|
const proxy = httpProxy__default["default"].createProxyServer({
|
|
33
|
-
target:
|
|
36
|
+
target: this.mkdocsTargetAddress
|
|
34
37
|
});
|
|
35
38
|
return (request) => {
|
|
36
39
|
var _a;
|
|
@@ -105,6 +108,10 @@ async function serve(opts) {
|
|
|
105
108
|
const mkdocsDockerAddr = `http://0.0.0.0:${opts.mkdocsPort}`;
|
|
106
109
|
const mkdocsLocalAddr = `http://127.0.0.1:${opts.mkdocsPort}`;
|
|
107
110
|
const mkdocsExpectedDevAddr = opts.docker ? mkdocsDockerAddr : mkdocsLocalAddr;
|
|
111
|
+
const { path: mkdocsYmlPath, configIsTemporary } = await pluginTechdocsNode.getMkdocsYml(
|
|
112
|
+
"./",
|
|
113
|
+
opts.siteName
|
|
114
|
+
);
|
|
108
115
|
let mkdocsServerHasStarted = false;
|
|
109
116
|
const mkdocsLogFunc = (data) => {
|
|
110
117
|
const logLines = data.toString().split("\n");
|
|
@@ -146,7 +153,7 @@ async function serve(opts) {
|
|
|
146
153
|
const httpServer = new HTTPServer(
|
|
147
154
|
previewAppPath,
|
|
148
155
|
port,
|
|
149
|
-
|
|
156
|
+
mkdocsExpectedDevAddr,
|
|
150
157
|
opts.verbose
|
|
151
158
|
);
|
|
152
159
|
httpServer.serve().catch((err) => {
|
|
@@ -161,7 +168,12 @@ Opening browser.`
|
|
|
161
168
|
);
|
|
162
169
|
});
|
|
163
170
|
await mkdocsServer.waitForSignal([mkdocsChildProcess]);
|
|
171
|
+
if (configIsTemporary) {
|
|
172
|
+
process.on("exit", async () => {
|
|
173
|
+
fs__default["default"].rmSync(mkdocsYmlPath, {});
|
|
174
|
+
});
|
|
175
|
+
}
|
|
164
176
|
}
|
|
165
177
|
|
|
166
178
|
exports["default"] = serve;
|
|
167
|
-
//# sourceMappingURL=serve-
|
|
179
|
+
//# sourceMappingURL=serve-5138af76.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve-5138af76.cjs.js","sources":["../../src/lib/httpServer.ts","../../src/commands/serve/serve.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport serveHandler from 'serve-handler';\nimport http from 'http';\nimport httpProxy from 'http-proxy';\nimport { createLogger } from './utility';\n\nexport default class HTTPServer {\n private readonly proxyEndpoint: string;\n private readonly backstageBundleDir: string;\n private readonly backstagePort: number;\n private readonly mkdocsTargetAddress: string;\n private readonly verbose: boolean;\n\n constructor(\n backstageBundleDir: string,\n backstagePort: number,\n mkdocsTargetAddress: string,\n verbose: boolean,\n ) {\n this.proxyEndpoint = '/api/techdocs/';\n this.backstageBundleDir = backstageBundleDir;\n this.backstagePort = backstagePort;\n this.mkdocsTargetAddress = mkdocsTargetAddress;\n this.verbose = verbose;\n }\n\n // Create a Proxy for mkdocs server\n private createProxy() {\n const proxy = httpProxy.createProxyServer({\n target: this.mkdocsTargetAddress,\n });\n\n return (request: http.IncomingMessage): [httpProxy, string] => {\n // If the request path is prefixed with this.proxyEndpoint, remove it.\n const proxyEndpointPath = new RegExp(`^${this.proxyEndpoint}`, 'i');\n const forwardPath = request.url?.replace(proxyEndpointPath, '') || '';\n\n return [proxy, forwardPath];\n };\n }\n\n public async serve(): Promise<http.Server> {\n return new Promise<http.Server>((resolve, reject) => {\n const proxyHandler = this.createProxy();\n const server = http.createServer(\n (request: http.IncomingMessage, response: http.ServerResponse) => {\n if (request.url?.startsWith(this.proxyEndpoint)) {\n const [proxy, forwardPath] = proxyHandler(request);\n\n proxy.on('error', (error: Error) => {\n reject(error);\n });\n\n response.setHeader('Access-Control-Allow-Origin', '*');\n response.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');\n\n request.url = forwardPath;\n proxy.web(request, response);\n return;\n }\n\n // This endpoint is used by the frontend to detect where the backend is running.\n if (request.url === '/.detect') {\n response.setHeader('Content-Type', 'text/plain');\n response.end('techdocs-cli-server');\n return;\n }\n\n serveHandler(request, response, {\n public: this.backstageBundleDir,\n trailingSlash: true,\n rewrites: [{ source: '**', destination: 'index.html' }],\n });\n },\n );\n\n const logger = createLogger({ verbose: false });\n server.listen(this.backstagePort, () => {\n if (this.verbose) {\n logger.info(\n `[techdocs-preview-bundle] Running local version of Backstage at http://localhost:${this.backstagePort}`,\n );\n }\n resolve(server);\n });\n\n server.on('error', (error: Error) => {\n reject(error);\n });\n });\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { OptionValues } from 'commander';\nimport path from 'path';\nimport openBrowser from 'react-dev-utils/openBrowser';\nimport { findPaths } from '@backstage/cli-common';\nimport HTTPServer from '../../lib/httpServer';\nimport { runMkdocsServer } from '../../lib/mkdocsServer';\nimport { LogFunc, waitForSignal } from '../../lib/run';\nimport { createLogger } from '../../lib/utility';\nimport { getMkdocsYml } from '@backstage/plugin-techdocs-node';\nimport fs from 'fs-extra';\n\nfunction findPreviewBundlePath(): string {\n try {\n return path.join(\n path.dirname(require.resolve('techdocs-cli-embedded-app/package.json')),\n 'dist',\n );\n } catch {\n // If the techdocs-cli-embedded-app package is not available it means we're\n // running a published package. For published packages the preview bundle is\n // copied to dist/embedded-app be the prepack script.\n //\n // This can be tested by running `yarn pack` and extracting the resulting tarball into a directory.\n // Within the extracted directory, run `npm install --only=prod`.\n // Once that's done you can test the CLI in any directory using `node <tmp-dir>/package <command>`.\n // eslint-disable-next-line no-restricted-syntax\n return findPaths(__dirname).resolveOwn('dist/embedded-app');\n }\n}\n\nfunction getPreviewAppPath(opts: OptionValues): string {\n return opts.previewAppBundlePath ?? findPreviewBundlePath();\n}\n\nexport default async function serve(opts: OptionValues) {\n const logger = createLogger({ verbose: opts.verbose });\n\n // Determine if we want to run in local dev mode or not\n // This will run the backstage http server on a different port and only used\n // for proxying mkdocs to the backstage app running locally (e.g. with webpack-dev-server)\n const isDevMode = Object.keys(process.env).includes('TECHDOCS_CLI_DEV_MODE')\n ? true\n : false;\n\n const backstageBackendPort = 7007;\n\n const mkdocsDockerAddr = `http://0.0.0.0:${opts.mkdocsPort}`;\n const mkdocsLocalAddr = `http://127.0.0.1:${opts.mkdocsPort}`;\n const mkdocsExpectedDevAddr = opts.docker\n ? mkdocsDockerAddr\n : mkdocsLocalAddr;\n\n const { path: mkdocsYmlPath, configIsTemporary } = await getMkdocsYml(\n './',\n opts.siteName,\n );\n\n let mkdocsServerHasStarted = false;\n const mkdocsLogFunc: LogFunc = data => {\n // Sometimes the lines contain an unnecessary extra new line\n const logLines = data.toString().split('\\n');\n const logPrefix = opts.docker ? '[docker/mkdocs]' : '[mkdocs]';\n logLines.forEach(line => {\n if (line === '') {\n return;\n }\n\n logger.verbose(`${logPrefix} ${line}`);\n\n // When the server has started, open a new browser tab for the user.\n if (\n !mkdocsServerHasStarted &&\n line.includes(`Serving on ${mkdocsExpectedDevAddr}`)\n ) {\n mkdocsServerHasStarted = true;\n }\n });\n };\n // mkdocs writes all of its logs to stderr by default, and not stdout.\n // https://github.com/mkdocs/mkdocs/issues/879#issuecomment-203536006\n // Had me questioning this whole implementation for half an hour.\n logger.info('Starting mkdocs server.');\n const mkdocsChildProcess = await runMkdocsServer({\n port: opts.mkdocsPort,\n dockerImage: opts.dockerImage,\n dockerEntrypoint: opts.dockerEntrypoint,\n dockerOptions: opts.dockerOption,\n useDocker: opts.docker,\n stdoutLogFunc: mkdocsLogFunc,\n stderrLogFunc: mkdocsLogFunc,\n });\n\n // Wait until mkdocs server has started so that Backstage starts with docs loaded\n // Takes 1-5 seconds\n for (let attempt = 0; attempt < 30; attempt++) {\n await new Promise(r => setTimeout(r, 3000));\n if (mkdocsServerHasStarted) {\n break;\n }\n logger.info('Waiting for mkdocs server to start...');\n }\n\n if (!mkdocsServerHasStarted) {\n logger.error(\n 'mkdocs server did not start. Exiting. Try re-running command with -v option for more details.',\n );\n }\n\n const port = isDevMode ? backstageBackendPort : opts.previewAppPort;\n const previewAppPath = getPreviewAppPath(opts);\n const httpServer = new HTTPServer(\n previewAppPath,\n port,\n mkdocsExpectedDevAddr,\n opts.verbose,\n );\n\n httpServer\n .serve()\n .catch(err => {\n logger.error('Failed to start HTTP server', err);\n mkdocsChildProcess.kill();\n process.exit(1);\n })\n .then(() => {\n // The last three things default/component/local/ don't matter. They can be anything.\n openBrowser(`http://localhost:${port}/docs/default/component/local/`);\n logger.info(\n `Serving docs in Backstage at http://localhost:${port}/docs/default/component/local/\\nOpening browser.`,\n );\n });\n\n await waitForSignal([mkdocsChildProcess]);\n\n if (configIsTemporary) {\n process.on('exit', async () => {\n fs.rmSync(mkdocsYmlPath, {});\n });\n }\n}\n"],"names":["httpProxy","http","serveHandler","createLogger","path","findPaths","getMkdocsYml","runMkdocsServer","openBrowser","waitForSignal","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAqB,UAAW,CAAA;AAAA,EAO9B,WACE,CAAA,kBAAA,EACA,aACA,EAAA,mBAAA,EACA,OACA,EAAA;AACA,IAAA,IAAA,CAAK,aAAgB,GAAA,gBAAA,CAAA;AACrB,IAAA,IAAA,CAAK,kBAAqB,GAAA,kBAAA,CAAA;AAC1B,IAAA,IAAA,CAAK,aAAgB,GAAA,aAAA,CAAA;AACrB,IAAA,IAAA,CAAK,mBAAsB,GAAA,mBAAA,CAAA;AAC3B,IAAA,IAAA,CAAK,OAAU,GAAA,OAAA,CAAA;AAAA,GACjB;AAAA;AAAA,EAGQ,WAAc,GAAA;AACpB,IAAM,MAAA,KAAA,GAAQA,8BAAU,iBAAkB,CAAA;AAAA,MACxC,QAAQ,IAAK,CAAA,mBAAA;AAAA,KACd,CAAA,CAAA;AAED,IAAA,OAAO,CAAC,OAAuD,KAAA;AA/CnE,MAAA,IAAA,EAAA,CAAA;AAiDM,MAAA,MAAM,oBAAoB,IAAI,MAAA,CAAO,CAAI,CAAA,EAAA,IAAA,CAAK,iBAAiB,GAAG,CAAA,CAAA;AAClE,MAAA,MAAM,gBAAc,EAAQ,GAAA,OAAA,CAAA,GAAA,KAAR,IAAa,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,OAAA,CAAQ,mBAAmB,EAAO,CAAA,KAAA,EAAA,CAAA;AAEnE,MAAO,OAAA,CAAC,OAAO,WAAW,CAAA,CAAA;AAAA,KAC5B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CAAA,CAAA;AAC/C,IAAA,kBAAA,CAAmB,IAAK,EAAA,CAAA;AACxB,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA,CAAA;AAAA,GACf,CACA,CAAA,IAAA,CAAK,MAAM;AAEV,IAAAC,+BAAA,CAAY,oBAAoB,IAAoC,CAAA,8BAAA,CAAA,CAAA,CAAA;AACpE,IAAO,MAAA,CAAA,IAAA;AAAA,MACL,CAAiD,8CAAA,EAAA,IAAA,CAAA;AAAA,gBAAA,CAAA;AAAA,KACnD,CAAA;AAAA,GACD,CAAA,CAAA;AAEH,EAAM,MAAAC,0BAAA,CAAc,CAAC,kBAAkB,CAAC,CAAA,CAAA;AAExC,EAAA,IAAI,iBAAmB,EAAA;AACrB,IAAQ,OAAA,CAAA,EAAA,CAAG,QAAQ,YAAY;AAC7B,MAAGC,sBAAA,CAAA,MAAA,CAAO,aAAe,EAAA,EAAE,CAAA,CAAA;AAAA,KAC5B,CAAA,CAAA;AAAA,GACH;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Backstage is an open platform for building developer portals"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json" crossorigin="use-credentials"/><link rel="icon" href="/favicon.ico"/><link rel="shortcut icon" href="/favicon.ico"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"/><title>Techdocs Preview App</title><script defer="defer" src="/static/runtime.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Backstage is an open platform for building developer portals"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json" crossorigin="use-credentials"/><link rel="icon" href="/favicon.ico"/><link rel="shortcut icon" href="/favicon.ico"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"/><title>Techdocs Preview App</title><script defer="defer" src="/static/runtime.a942e8cf.js"></script><script defer="defer" src="/static/module-material-ui.e7d0407d.js"></script><script defer="defer" src="/static/module-lodash.f07e54c1.js"></script><script defer="defer" src="/static/module-date-fns.7dd2cc1f.js"></script><script defer="defer" src="/static/module-yaml.cb32d5ca.js"></script><script defer="defer" src="/static/module-ajv.07e5c2aa.js"></script><script defer="defer" src="/static/module-material-table.ac270938.js"></script><script defer="defer" src="/static/module-luxon.9cc2c5ac.js"></script><script defer="defer" src="/static/module-octokit.991a0781.js"></script><script defer="defer" src="/static/module-react-dom.5abdac04.js"></script><script defer="defer" src="/static/module-zod.49ffd80f.js"></script><script defer="defer" src="/static/module-react-beautiful-dnd.97cccd01.js"></script><script defer="defer" src="/static/module-remix-run.b9acb514.js"></script><script defer="defer" src="/static/vendor.a942e8cf.js"></script><script defer="defer" src="/static/main.a942e8cf.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[5837],{95837:function(F,e,s){s.r(e),s.d(e,{CatalogPage:function(){return h},DefaultCatalogPage:function(){return c}});var t=s(52322),P=s(2784),g=s(79635),l=s(23196),i=s(25248),n=s(56941),u=s(19625),x=s(86359);const j=()=>(0,i.yx)();function c(o){const{columns:r,actions:m,initiallySelectedFilter:C="owned",initialKind:f="component",tableOptions:p={},emptyContent:v}=o;var a;const y=(a=(0,i.h_)(i.Ds).getOptionalString("organization.name"))!==null&&a!==void 0?a:"Backstage",d=(0,i.tg)(u.yw),{createButtonTitle:O}=j();return(0,t.jsx)(l.g9,{title:`${y} Catalog`,themeId:"home",children:(0,t.jsxs)(l.VY,{children:[(0,t.jsxs)(l.yW,{title:"",children:[(0,t.jsx)(l.XF,{title:O,to:d&&d()}),(0,t.jsx)(l.qt,{children:"All your software catalog entities"})]}),(0,t.jsx)(n.UO,{children:(0,t.jsxs)(n._i,{children:[(0,t.jsxs)(n._i.Filters,{children:[(0,t.jsx)(n.tW,{initialFilter:f}),(0,t.jsx)(n.sL,{}),(0,t.jsx)(n.EW,{initialFilter:C}),(0,t.jsx)(n.dq,{}),(0,t.jsx)(n.df,{}),(0,t.jsx)(n.xE,{}),(0,t.jsx)(n.nl,{})]}),(0,t.jsx)(n._i.Content,{children:(0,t.jsx)(x.E,{columns:r,actions:m,tableOptions:p,emptyContent:v})})]})})]})})}function h(o){return(0,g.pC)()||(0,t.jsx)(c,{...o})}}}]);})();
|
|
2
2
|
|
|
3
|
-
//# sourceMappingURL=5837.
|
|
3
|
+
//# sourceMappingURL=5837.239cccbd.chunk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://techdocs-cli-embedded-app/../../plugins/catalog/src/options.ts","webpack://techdocs-cli-embedded-app/../../plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx","webpack://techdocs-cli-embedded-app/../../plugins/catalog/src/components/CatalogPage/CatalogPage.tsx"],"names":["useCatalogPluginOptions","usePluginOptions","DefaultCatalogPage","props","columns","actions","initiallySelectedFilter","initialKind","tableOptions","emptyContent","useApi","orgName","configApiRef","getOptionalString","createComponentLink","useRouteRef","createComponentRouteRef","createButtonTitle","PageWithHeader","title","themeId","Content","ContentHeader","CreateButton","to","SupportButton","EntityListProvider","CatalogFilterLayout","EntityKindPicker","initialFilter","EntityTypePicker","UserListPicker","EntityOwnerPicker","EntityLifecyclePicker","EntityTagPicker","EntityProcessingStatusPicker","CatalogTable","CatalogPage","useOutlet"],"mappings":"uUA2BO,MAAMA,EAA0B,K,EACrCC,MAAgBA,EC6BX,SAASC,EAAmBC,EAAgC,CACjE,KAAM,CACJC,UACAC,UACAC,0BAA0B,QAC1BC,cAAc,YACdC,eAAe,CAAC,EAChBC,cAAY,EACVN,E,IAEFO,EADF,MAAMC,GACJD,G,EAAAA,MAAOE,IAAYA,EAAEC,kBAAkB,mBAAmB,KAAnB,MAAvCH,aAA+D,YAC3DI,G,EAAsBC,MAAYC,IAAuBA,EAEzD,CAAEC,mBAAkB,EAAIjB,EAAwB,EAEtD,O,EACE,OAACkB,KAAcA,CAACC,MAAO,GAAGR,YAAmBS,QAAQ,O,YACnD,QAACC,KAAOA,C,aACN,QAACC,KAAaA,CAACH,MAAM,G,aACnB,OAACI,KAAYA,CACXJ,MAAOF,EACPO,GAAIV,GAAuBA,EAAoB,C,MAEjD,OAACW,KAAaA,C,SAAC,oC,SAEjB,OAACC,KAAkBA,C,YACjB,QAACC,KAAmBA,C,aAClB,QAACA,aAA2B,C,aAC1B,OAACC,KAAgBA,CAACC,cAAetB,C,MACjC,OAACuB,KAAgBA,K,EACjB,OAACC,KAAcA,CAACF,cAAevB,C,MAC/B,OAAC0B,KAAiBA,K,EAClB,OAACC,KAAqBA,K,EACtB,OAACC,KAAeA,K,EAChB,OAACC,KAA4BA,G,OAE/B,OAACR,aAA2B,C,YAC1B,OAACS,IAAYA,CACXhC,QAASA,EACTC,QAASA,EACTG,aAAcA,EACdC,aAAcA,C,cAQ9B,CCnFO,SAAS4B,EAAYlC,EAAgC,CAG1D,O,EAFemC,MAAU,I,EAER,OAACpC,EAAkBA,CAAE,GAAGC,C,EAC3C,C","file":"static/5837.
|
|
1
|
+
{"version":3,"sources":["webpack://techdocs-cli-embedded-app/../../plugins/catalog/src/options.ts","webpack://techdocs-cli-embedded-app/../../plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx","webpack://techdocs-cli-embedded-app/../../plugins/catalog/src/components/CatalogPage/CatalogPage.tsx"],"names":["useCatalogPluginOptions","usePluginOptions","DefaultCatalogPage","props","columns","actions","initiallySelectedFilter","initialKind","tableOptions","emptyContent","useApi","orgName","configApiRef","getOptionalString","createComponentLink","useRouteRef","createComponentRouteRef","createButtonTitle","PageWithHeader","title","themeId","Content","ContentHeader","CreateButton","to","SupportButton","EntityListProvider","CatalogFilterLayout","EntityKindPicker","initialFilter","EntityTypePicker","UserListPicker","EntityOwnerPicker","EntityLifecyclePicker","EntityTagPicker","EntityProcessingStatusPicker","CatalogTable","CatalogPage","useOutlet"],"mappings":"uUA2BO,MAAMA,EAA0B,K,EACrCC,MAAgBA,EC6BX,SAASC,EAAmBC,EAAgC,CACjE,KAAM,CACJC,UACAC,UACAC,0BAA0B,QAC1BC,cAAc,YACdC,eAAe,CAAC,EAChBC,cAAY,EACVN,E,IAEFO,EADF,MAAMC,GACJD,G,EAAAA,MAAOE,IAAYA,EAAEC,kBAAkB,mBAAmB,KAAnB,MAAvCH,aAA+D,YAC3DI,G,EAAsBC,MAAYC,IAAuBA,EAEzD,CAAEC,mBAAkB,EAAIjB,EAAwB,EAEtD,O,EACE,OAACkB,KAAcA,CAACC,MAAO,GAAGR,YAAmBS,QAAQ,O,YACnD,QAACC,KAAOA,C,aACN,QAACC,KAAaA,CAACH,MAAM,G,aACnB,OAACI,KAAYA,CACXJ,MAAOF,EACPO,GAAIV,GAAuBA,EAAoB,C,MAEjD,OAACW,KAAaA,C,SAAC,oC,SAEjB,OAACC,KAAkBA,C,YACjB,QAACC,KAAmBA,C,aAClB,QAACA,aAA2B,C,aAC1B,OAACC,KAAgBA,CAACC,cAAetB,C,MACjC,OAACuB,KAAgBA,K,EACjB,OAACC,KAAcA,CAACF,cAAevB,C,MAC/B,OAAC0B,KAAiBA,K,EAClB,OAACC,KAAqBA,K,EACtB,OAACC,KAAeA,K,EAChB,OAACC,KAA4BA,G,OAE/B,OAACR,aAA2B,C,YAC1B,OAACS,IAAYA,CACXhC,QAASA,EACTC,QAASA,EACTG,aAAcA,EACdC,aAAcA,C,cAQ9B,CCnFO,SAAS4B,EAAYlC,EAAgC,CAG1D,O,EAFemC,MAAU,I,EAER,OAACpC,EAAkBA,CAAE,GAAGC,C,EAC3C,C","file":"static/5837.239cccbd.chunk.js","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 { usePluginOptions } from '@backstage/core-plugin-api';\n\nexport type CatalogPluginOptions = {\n createButtonTitle: string;\n};\n\n/** @ignore */\nexport type CatalogInputPluginOptions = {\n createButtonTitle: string;\n};\n\nexport const useCatalogPluginOptions = () =>\n usePluginOptions<CatalogPluginOptions>();\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Content,\n ContentHeader,\n CreateButton,\n PageWithHeader,\n SupportButton,\n TableColumn,\n TableProps,\n} from '@backstage/core-components';\nimport { configApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport {\n CatalogFilterLayout,\n EntityLifecyclePicker,\n EntityListProvider,\n EntityProcessingStatusPicker,\n EntityOwnerPicker,\n EntityTagPicker,\n EntityTypePicker,\n UserListFilterKind,\n UserListPicker,\n EntityKindPicker,\n} from '@backstage/plugin-catalog-react';\nimport React, { ReactNode } from 'react';\nimport { createComponentRouteRef } from '../../routes';\nimport { CatalogTable, CatalogTableRow } from '../CatalogTable';\nimport { useCatalogPluginOptions } from '../../options';\n\n/**\n * Props for root catalog pages.\n *\n * @public\n */\nexport interface DefaultCatalogPageProps {\n initiallySelectedFilter?: UserListFilterKind;\n columns?: TableColumn<CatalogTableRow>[];\n actions?: TableProps<CatalogTableRow>['actions'];\n initialKind?: string;\n tableOptions?: TableProps<CatalogTableRow>['options'];\n emptyContent?: ReactNode;\n}\n\nexport function DefaultCatalogPage(props: DefaultCatalogPageProps) {\n const {\n columns,\n actions,\n initiallySelectedFilter = 'owned',\n initialKind = 'component',\n tableOptions = {},\n emptyContent,\n } = props;\n const orgName =\n useApi(configApiRef).getOptionalString('organization.name') ?? 'Backstage';\n const createComponentLink = useRouteRef(createComponentRouteRef);\n\n const { createButtonTitle } = useCatalogPluginOptions();\n\n return (\n <PageWithHeader title={`${orgName} Catalog`} themeId=\"home\">\n <Content>\n <ContentHeader title=\"\">\n <CreateButton\n title={createButtonTitle}\n to={createComponentLink && createComponentLink()}\n />\n <SupportButton>All your software catalog entities</SupportButton>\n </ContentHeader>\n <EntityListProvider>\n <CatalogFilterLayout>\n <CatalogFilterLayout.Filters>\n <EntityKindPicker initialFilter={initialKind} />\n <EntityTypePicker />\n <UserListPicker initialFilter={initiallySelectedFilter} />\n <EntityOwnerPicker />\n <EntityLifecyclePicker />\n <EntityTagPicker />\n <EntityProcessingStatusPicker />\n </CatalogFilterLayout.Filters>\n <CatalogFilterLayout.Content>\n <CatalogTable\n columns={columns}\n actions={actions}\n tableOptions={tableOptions}\n emptyContent={emptyContent}\n />\n </CatalogFilterLayout.Content>\n </CatalogFilterLayout>\n </EntityListProvider>\n </Content>\n </PageWithHeader>\n );\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { useOutlet } from 'react-router-dom';\nimport {\n DefaultCatalogPage,\n DefaultCatalogPageProps,\n} from './DefaultCatalogPage';\n\nexport function CatalogPage(props: DefaultCatalogPageProps) {\n const outlet = useOutlet();\n\n return outlet || <DefaultCatalogPage {...props} />;\n}\n"],"sourceRoot":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[6051],{76051:function(he,j,d){d.r(j),d.d(j,{RealLogViewer:function(){return ue}});var h=d(52322),Z=d(95544),y=d(61837),U=d(19353),W=d(72779),b=d.n(W),g=d(2784),D=d(79635),G=d(7688),P=d(50166),$=d(46212);const L=(0,$.Z)(),B=/\n\r?/g,I=Object.fromEntries(Object.entries({1:e=>({...e,bold:!0}),3:e=>({...e,italic:!0}),4:e=>({...e,underline:!0}),22:({bold:e,...n})=>n,23:({italic:e,...n})=>n,24:({underline:e,...n})=>n,30:e=>({...e,foreground:"black"}),31:e=>({...e,foreground:"red"}),32:e=>({...e,foreground:"green"}),33:e=>({...e,foreground:"yellow"}),34:e=>({...e,foreground:"blue"}),35:e=>({...e,foreground:"magenta"}),36:e=>({...e,foreground:"cyan"}),37:e=>({...e,foreground:"white"}),39:({foreground:e,...n})=>n,90:e=>({...e,foreground:"grey"}),40:e=>({...e,background:"black"}),41:e=>({...e,background:"red"}),42:e=>({...e,background:"green"}),43:e=>({...e,background:"yellow"}),44:e=>({...e,background:"blue"}),45:e=>({...e,background:"magenta"}),46:e=>({...e,background:"cyan"}),47:e=>({...e,background:"white"}),49:({background:e,...n})=>n}).map(([e,n])=>[`\x1B[${e}m`,n]));class C{lastChunk(){return this.chunks[this.chunks.length-1]}replaceLastChunk(n){n&&(this.chunks.splice(this.chunks.length-1,1,...n),this.text=this.chunks.map(t=>t.text).join("").toLocaleLowerCase("en-US"))}constructor(n=1,t=[]){this.lineNumber=n,this.chunks=t,this.text=t.map(s=>s.text).join("").toLocaleLowerCase("en-US")}}class Y{process(n){if(this.text===n)return this.lines;if(n.startsWith(this.text)){var t;const r=this.lines.length>0?this.lines.length-1:0;var s;const i=(s=this.lines[r])!==null&&s!==void 0?s:new C,c=i.lastChunk();var o;const l=this.processLines(((o=c==null?void 0:c.text)!==null&&o!==void 0?o:"")+n.slice(this.text.length),c==null?void 0:c.modifiers,i==null?void 0:i.lineNumber);i.replaceLastChunk((t=l[0])===null||t===void 0?void 0:t.chunks),this.lines[r]=i,this.lines.push(...l.slice(1))}else this.lines=this.processLines(n);return this.text=n,this.lines}constructor(){this.text="",this.lines=[],this.processLines=(n,t={},s=1)=>{const o=[];let r=t,i=s,c=0;for(B.lastIndex=0;;){const u=B.exec(n);if(!u){const m=this.processText(n.slice(c),r);return o.push(new C(i,m)),o}const a=n.slice(c,u.index);c=u.index+u[0].length;const f=this.processText(a,r);o.push(new C(i,f));var l;r=(l=f[f.length-1].modifiers)!==null&&l!==void 0?l:r,i+=1}},this.processText=(n,t)=>{const s=[];let o=t,r=0;for(L.lastIndex=0;;){const i=L.exec(n);if(!i)return s.push({text:n.slice(r),modifiers:o}),s;const c=n.slice(r,i.index);s.push({text:c,modifiers:o}),r=i.index+i[0].length,o=this.processCode(i[0],o)}},this.processCode=(n,t)=>{var s,o;return(o=(s=I[n])===null||s===void 0?void 0:s.call(I,t))!==null&&o!==void 0?o:t}}}var w=d(74600),R=d.n(w);function J(e,n){const t=new Array;if(n.bold&&t.push(e.modifierBold),n.italic&&t.push(e.modifierItalic),n.underline&&t.push(e.modifierUnderline),n.foreground){const s=`modifierForeground${R()(n.foreground)}`;t.push(e[s])}if(n.background){const s=`modifierBackground${R()(n.background)}`;t.push(e[s])}return t.length>0?t.join(" "):void 0}function Q(e,n){if(!n||!e.includes(n))return;const t=new Array;let s=0;for(;;){const o=e.indexOf(n,s);if(o===-1)break;const r=o+n.length;t.push({start:o,end:r}),s=r}return t}function X(e,n){const t=Q(e.text,n);if(!t)return e.chunks;const s=new Array;let o=0,r=0,i=t[r];for(const c of e.chunks){const{text:l,modifiers:u}=c;if(!i||o+l.length<i.start){s.push(c),o+=l.length;continue}let a=0;for(;i;){const m=Math.max(i.start-o,0);if(m>l.length)break;const v=Math.min(i.end-o,l.length);if(m>a&&s.push({text:l.slice(a,m),modifiers:u}),v>m&&s.push({modifiers:u,highlight:r,text:l.slice(m,v)}),a=v,i.end-o===v)r+=1,i=t[r];else break}a<l.length&&s.push({text:l.slice(a),modifiers:u}),o+=l.length}return s}function q({line:e,classes:n,searchText:t,highlightResultIndex:s}){const o=(0,g.useMemo)(()=>X(e,t),[e,t]),r=(0,g.useMemo)(()=>o.map(({text:i,modifiers:c,highlight:l},u)=>(0,h.jsx)("span",{className:b()(J(n,c),l!==void 0&&(l===s?n.textSelectedHighlight:n.textHighlight)),children:i},u)),[o,s,n]);return(0,h.jsx)(h.Fragment,{children:r})}var _=d(86619),ee=d(90436),ne=d(48049),te=d(51209),F=d(36444);function oe(e){const{resultCount:n,resultIndexStep:t,toggleShouldFilter:s}=e;var o;const r=(o=e.resultIndex)!==null&&o!==void 0?o:0,i=c=>{c.key==="Enter"&&(c.metaKey||c.ctrlKey||c.altKey?s():t(c.shiftKey))};return(0,h.jsxs)(h.Fragment,{children:[n!==void 0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(y.Z,{size:"small",onClick:()=>t(!0),children:(0,h.jsx)(ne.Z,{})}),(0,h.jsxs)(ee.Z,{children:[Math.min(r+1,n),"/",n]}),(0,h.jsx)(y.Z,{size:"small",onClick:()=>t(),children:(0,h.jsx)(te.Z,{})})]}),(0,h.jsx)(_.Z,{size:"small",variant:"standard",placeholder:"Search",value:e.searchInput,onKeyPress:i,onChange:c=>e.setSearchInput(c.target.value)}),(0,h.jsx)(y.Z,{size:"small",onClick:s,children:e.shouldFilter?(0,h.jsx)(F.Z,{color:"primary"}):(0,h.jsx)(F.Z,{color:"disabled"})})]})}var se=d(79692),M=d(41128),k=d(31754),N=d(66054),T=d(81463),A=d(34505),E=d(57186),z=d(32720),K=d(92901),H=d(45410);const O=40,re=(0,se.Z)(e=>({root:{background:e.palette.background.paper},header:{height:O,display:"flex",alignItems:"center",justifyContent:"flex-end"},log:{fontFamily:'"Monaco", monospace',fontSize:e.typography.pxToRem(12)},line:{position:"relative",whiteSpace:"pre","&:hover":{background:e.palette.action.hover}},lineSelected:{background:e.palette.action.selected,"&:hover":{background:e.palette.action.selected}},lineCopyButton:{position:"absolute",paddingTop:0,paddingBottom:0},lineNumber:{display:"inline-block",textAlign:"end",width:60,marginRight:e.spacing(1),cursor:"pointer"},textHighlight:{background:(0,M.Fq)(e.palette.info.main,.15)},textSelectedHighlight:{background:(0,M.Fq)(e.palette.info.main,.4)},modifierBold:{fontWeight:e.typography.fontWeightBold},modifierItalic:{fontStyle:"italic"},modifierUnderline:{textDecoration:"underline"},modifierForegroundBlack:{color:k.Z.black},modifierForegroundRed:{color:N.Z[500]},modifierForegroundGreen:{color:T.Z[500]},modifierForegroundYellow:{color:A.Z[500]},modifierForegroundBlue:{color:E.Z[500]},modifierForegroundMagenta:{color:z.Z[500]},modifierForegroundCyan:{color:K.Z[500]},modifierForegroundWhite:{color:k.Z.white},modifierForegroundGrey:{color:H.Z[500]},modifierBackgroundBlack:{background:k.Z.black},modifierBackgroundRed:{background:N.Z[500]},modifierBackgroundGreen:{background:T.Z[500]},modifierBackgroundYellow:{background:A.Z[500]},modifierBackgroundBlue:{background:E.Z[500]},modifierBackgroundMagenta:{background:z.Z[500]},modifierBackgroundCyan:{background:K.Z[500]},modifierBackgroundWhite:{background:k.Z.white},modifierBackgroundGrey:{background:H.Z[500]}}),{name:"BackstageLogViewer"});var ie=d(96686);function le(e,n){if(!n)return{lines:e};const t=[],s=[];for(const o of e)if(o.text.includes(n)){t.push(o);let r=0,i=0;for(;;){const c=o.text.indexOf(n,r);if(c===-1)break;s.push({lineNumber:o.lineNumber,lineIndex:i++}),r=c+n.length}}return{lines:t,results:s}}function ce(e){var n;const[t,s]=(0,g.useState)(""),o=t.toLocaleLowerCase("en-US"),[r,i]=(0,g.useState)(0),[c,l]=(0,ie.O)(!1),u=(0,g.useMemo)(()=>le(e,o),[e,o]),a=u.results?u.results[Math.min(r,u.results.length-1)]:void 0,f=(n=u.results)===null||n===void 0?void 0:n.length,m=v=>{if(v){if(f!==void 0){const x=Math.min(r-1,f-2);i(x<0?f-1:x)}}else if(f!==void 0){const x=r+1;i(x>=f?0:x)}};return{lines:c?u.lines:e,searchText:o,searchInput:t,setSearchInput:s,shouldFilter:c,toggleShouldFilter:l,resultCount:f,resultIndex:r,resultIndexStep:m,resultLine:a==null?void 0:a.lineNumber,resultLineIndex:a==null?void 0:a.lineIndex}}var V=d(25248),de=d(95074);function ae(e){const n=(0,V.h_)(V.VE),[t,s]=(0,g.useState)(),o=t?Math.min(t.start,t.end):void 0,r=t?Math.max(t.start,t.end):void 0,[{error:i},c]=(0,de.Z)();return(0,g.useEffect)(()=>{i&&n.post(i)},[i,n]),{shouldShowButton(l){return o===l||r===l},isSelected(l){return t?o<=l&&l<=r:!1},setSelection(l,u){s(u?a=>a?{start:a.start,end:l}:{start:l,end:l}:a=>(a==null?void 0:a.start)===l&&(a==null?void 0:a.end)===l?void 0:{start:l,end:l})},copySelection(){if(t){const l=e.slice(Math.min(t.start,t.end)-1,Math.max(t.start,t.end)).map(u=>u.chunks.map(a=>a.text).join("")).join(`
|
|
2
2
|
`);c(l),s(void 0)}}}}function ue(e){const n=re({classes:e.classes}),t=(0,g.useRef)(null),o=(0,g.useMemo)(()=>new Y,[]).process(e.text),r=ce(o),i=ae(o),c=(0,D.TH)();(0,g.useEffect)(()=>{r.resultLine!==void 0&&t.current&&t.current.scrollToItem(r.resultLine-1,"center")},[r.resultLine]),(0,g.useEffect)(()=>{if(c.hash){const u=parseInt(c.hash.replace(/\D/g,""),10);i.setSelection(u,!1)}},[]);const l=(u,a)=>{i.setSelection(u,a.shiftKey)};return(0,h.jsx)(G.Z,{children:({height:u,width:a})=>(0,h.jsxs)(Z.Z,{style:{width:a,height:u},className:n.root,children:[(0,h.jsx)(Z.Z,{className:n.header,children:(0,h.jsx)(oe,{...r})}),(0,h.jsx)(P.t7,{ref:t,className:n.log,height:u-O,width:a,itemData:r.lines,itemSize:20,itemCount:r.lines.length,children:({index:f,style:m,data:v})=>{const x=v[f],{lineNumber:p}=x;return(0,h.jsxs)(Z.Z,{style:{...m},className:b()(n.line,{[n.lineSelected]:i.isSelected(p)}),children:[i.shouldShowButton(p)&&(0,h.jsx)(y.Z,{"data-testid":"copy-button",size:"small",className:n.lineCopyButton,onClick:()=>i.copySelection(),children:(0,h.jsx)(U.Z,{fontSize:"inherit"})}),(0,h.jsx)("a",{role:"row",target:"_self",href:`#line-${p}`,className:n.lineNumber,onClick:S=>l(p,S),onKeyPress:S=>l(p,S),children:p}),(0,h.jsx)(q,{line:x,classes:n,searchText:r.searchText,highlightResultIndex:r.resultLine===p?r.resultLineIndex:void 0})]})}})]})})}}}]);})();
|
|
3
3
|
|
|
4
|
-
//# sourceMappingURL=6051.
|
|
4
|
+
//# sourceMappingURL=6051.66d9ff08.chunk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/AnsiProcessor.ts","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/LogLine.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/LogViewerControls.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/styles.ts","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/useLogViewerSearch.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/useLogViewerSelection.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/RealLogViewer.tsx"],"names":["ansiRegex","ansiRegexMaker","newlineRegex","codeModifiers","Object","fromEntries","entries","m","bold","italic","underline","_","foreground","background","map","code","modifier","AnsiLine","lastChunk","chunks","length","replaceLastChunk","newChunks","splice","text","c","join","toLocaleLowerCase","constructor","lineNumber","AnsiProcessor","process","lines","startsWith","newLines","lastLineIndex","lastLine","processLines","slice","modifiers","push","startingLineNumber","currentModifiers","currentLineNumber","prevIndex","lastIndex","match","exec","processText","line","index","fullText","processCode","getModifierClasses","classes","classNames","Array","modifierBold","modifierItalic","modifierUnderline","key","startCase","undefined","findSearchResults","searchText","includes","searchResults","offset","start","indexOf","end","calculateHighlightedChunks","results","lineOffset","resultIndex","result","chunk","localOffset","localStart","Math","max","localEnd","min","highlight","LogLine","highlightResultIndex","useMemo","elements","span","className","classnames","textSelectedHighlight","textHighlight","LogViewerControls","props","resultCount","resultIndexStep","toggleShouldFilter","handleKeyPress","event","metaKey","ctrlKey","altKey","shiftKey","IconButton","size","onClick","ChevronLeftIcon","Typography","ChevronRightIcon","TextField","variant","placeholder","value","searchInput","onKeyPress","onChange","e","setSearchInput","target","shouldFilter","FilterListIcon","color","HEADER_SIZE","useStyles","makeStyles","theme","root","palette","paper","header","height","display","alignItems","justifyContent","log","fontFamily","fontSize","typography","pxToRem","position","whiteSpace","action","hover","lineSelected","selected","lineCopyButton","paddingTop","paddingBottom","textAlign","width","marginRight","spacing","cursor","alpha","info","main","fontWeight","fontWeightBold","fontStyle","textDecoration","modifierForegroundBlack","colors","modifierForegroundRed","modifierForegroundGreen","modifierForegroundYellow","modifierForegroundBlue","modifierForegroundMagenta","modifierForegroundCyan","modifierForegroundWhite","modifierForegroundGrey","modifierBackgroundBlack","modifierBackgroundRed","modifierBackgroundGreen","modifierBackgroundYellow","modifierBackgroundBlue","modifierBackgroundMagenta","modifierBackgroundCyan","modifierBackgroundWhite","modifierBackgroundGrey","name","applySearchFilter","matchingLines","lineResultIndex","lineIndex","useLogViewerSearch","filter","useState","setResultIndex","useToggle","searchResult","decrement","next","resultLine","resultLineIndex","useLogViewerSelection","errorApi","useApi","errorApiRef","sel","setSelection","error","copyToClipboard","useCopyToClipboard","useEffect","post","shouldShowButton","isSelected","add","s","copySelection","copyText","l","RealLogViewer","listRef","useRef","search","selection","location","useLocation","current","scrollToItem","hash","parseInt","replace","handleSelectLine","AutoSizer","Box","style","FixedSizeList","ref","itemData","itemSize","itemCount","data","data-testid","CopyIcon","a","role","href"],"mappings":"iUAkBA,MAAMA,G,EAAYC,KAAe,EAC3BC,EAAe,SAGfC,EAAgBC,OAAOC,YAC3BD,OAAOE,QAAQ,CACb,EAAGC,IAAM,CAAE,GAAGA,EAAGC,KAAM,EAAK,GAC5B,EAAGD,IAAM,CAAE,GAAGA,EAAGE,OAAQ,EAAK,GAC9B,EAAGF,IAAM,CAAE,GAAGA,EAAGG,UAAW,EAAK,GACjC,GAAI,CAAC,CAAEF,KAAMG,KAAMJ,CAAE,IAAMA,EAC3B,GAAI,CAAC,CAAEE,OAAQE,KAAMJ,CAAE,IAAMA,EAC7B,GAAI,CAAC,CAAEG,UAAWC,KAAMJ,CAAE,IAAMA,EAChC,GAAIA,IAAM,CAAE,GAAGA,EAAGK,WAAY,OAAQ,GACtC,GAAIL,IAAM,CAAE,GAAGA,EAAGK,WAAY,KAAM,GACpC,GAAIL,IAAM,CAAE,GAAGA,EAAGK,WAAY,OAAQ,GACtC,GAAIL,IAAM,CAAE,GAAGA,EAAGK,WAAY,QAAS,GACvC,GAAIL,IAAM,CAAE,GAAGA,EAAGK,WAAY,MAAO,GACrC,GAAIL,IAAM,CAAE,GAAGA,EAAGK,WAAY,SAAU,GACxC,GAAIL,IAAM,CAAE,GAAGA,EAAGK,WAAY,MAAO,GACrC,GAAIL,IAAM,CAAE,GAAGA,EAAGK,WAAY,OAAQ,GACtC,GAAI,CAAC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EAAQ0F,cAAeyE,EAAUV,WAAWlL,CAAU,CACzD,CAAC,E,UAEA4L,EAAUX,iBAAiBjL,CAAU,I,EACpC,OAAC2E,IAAUA,CACTmI,cAAY,cACZlI,KAAK,QACLhB,UAAWnC,EAAQ4F,eACnBxC,QAAS,IAAM+G,EAAUP,cAAc,E,YAEvC,OAAC0B,IAAQA,CAACnG,SAAS,S,QAGvB,OAACoG,KACCC,KAAK,MACLvH,OAAO,QACPwH,KAAM,SAASlN,IACf4D,UAAWnC,EAAQzB,WACnB6E,QAASP,GAAS8H,EAAiBpM,EAAYsE,CAAK,EACpDgB,WAAYhB,GAAS8H,EAAiBpM,EAAYsE,CAAK,E,SAEtDtE,C,MAEH,OAACuD,EAAOA,CACNnC,KAAMA,EACNK,QAASA,EACTU,WAAYwJ,EAAOxJ,WACnBqB,qBACEmI,EAAOvB,aAAepK,EAClB2L,EAAOtB,gBACPpI,M,KAKd,C,OAMZ,C","file":"static/6051.e3b445b2.chunk.js","sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport ansiRegexMaker from 'ansi-regex';\n\nconst ansiRegex = ansiRegexMaker();\nconst newlineRegex = /\\n\\r?/g;\n\n// A mapping of how each escape code changes the modifiers\nconst codeModifiers = Object.fromEntries(\n Object.entries({\n 1: m => ({ ...m, bold: true }),\n 3: m => ({ ...m, italic: true }),\n 4: m => ({ ...m, underline: true }),\n 22: ({ bold: _, ...m }) => m,\n 23: ({ italic: _, ...m }) => m,\n 24: ({ underline: _, ...m }) => m,\n 30: m => ({ ...m, foreground: 'black' }),\n 31: m => ({ ...m, foreground: 'red' }),\n 32: m => ({ ...m, foreground: 'green' }),\n 33: m => ({ ...m, foreground: 'yellow' }),\n 34: m => ({ ...m, foreground: 'blue' }),\n 35: m => ({ ...m, foreground: 'magenta' }),\n 36: m => ({ ...m, foreground: 'cyan' }),\n 37: m => ({ ...m, foreground: 'white' }),\n 39: ({ foreground: _, ...m }) => m,\n 90: m => ({ ...m, foreground: 'grey' }),\n 40: m => ({ ...m, background: 'black' }),\n 41: m => ({ ...m, background: 'red' }),\n 42: m => ({ ...m, background: 'green' }),\n 43: m => ({ ...m, background: 'yellow' }),\n 44: m => ({ ...m, background: 'blue' }),\n 45: m => ({ ...m, background: 'magenta' }),\n 46: m => ({ ...m, background: 'cyan' }),\n 47: m => ({ ...m, background: 'white' }),\n 49: ({ background: _, ...m }) => m,\n } as Record<string, (m: ChunkModifiers) => ChunkModifiers>).map(\n ([code, modifier]) => [`\\x1b[${code}m`, modifier],\n ),\n);\n\nexport type AnsiColor =\n | 'black'\n | 'red'\n | 'green'\n | 'yellow'\n | 'blue'\n | 'magenta'\n | 'cyan'\n | 'white'\n | 'grey';\n\nexport interface ChunkModifiers {\n foreground?: AnsiColor;\n background?: AnsiColor;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n}\n\nexport interface AnsiChunk {\n text: string;\n modifiers: ChunkModifiers;\n}\n\nexport class AnsiLine {\n text: string;\n\n constructor(\n readonly lineNumber: number = 1,\n readonly chunks: AnsiChunk[] = [],\n ) {\n this.text = chunks\n .map(c => c.text)\n .join('')\n .toLocaleLowerCase('en-US');\n }\n\n lastChunk(): AnsiChunk | undefined {\n return this.chunks[this.chunks.length - 1];\n }\n\n replaceLastChunk(newChunks?: AnsiChunk[]) {\n if (newChunks) {\n this.chunks.splice(this.chunks.length - 1, 1, ...newChunks);\n this.text = this.chunks\n .map(c => c.text)\n .join('')\n .toLocaleLowerCase('en-US');\n }\n }\n}\n\nexport class AnsiProcessor {\n private text: string = '';\n private lines: AnsiLine[] = [];\n\n /**\n * Processes a chunk of text while keeping internal state that optimizes\n * subsequent processing that appends to the text.\n */\n process(text: string): AnsiLine[] {\n if (this.text === text) {\n return this.lines;\n }\n\n if (text.startsWith(this.text)) {\n const lastLineIndex = this.lines.length > 0 ? this.lines.length - 1 : 0;\n const lastLine = this.lines[lastLineIndex] ?? new AnsiLine();\n const lastChunk = lastLine.lastChunk();\n\n const newLines = this.processLines(\n (lastChunk?.text ?? '') + text.slice(this.text.length),\n lastChunk?.modifiers,\n lastLine?.lineNumber,\n );\n lastLine.replaceLastChunk(newLines[0]?.chunks);\n\n this.lines[lastLineIndex] = lastLine;\n this.lines.push(...newLines.slice(1));\n } else {\n this.lines = this.processLines(text);\n }\n this.text = text;\n\n return this.lines;\n }\n\n // Split a chunk of text up into lines and process each line individually\n private processLines = (\n text: string,\n modifiers: ChunkModifiers = {},\n startingLineNumber: number = 1,\n ): AnsiLine[] => {\n const lines: AnsiLine[] = [];\n\n let currentModifiers = modifiers;\n let currentLineNumber = startingLineNumber;\n\n let prevIndex = 0;\n newlineRegex.lastIndex = 0;\n for (;;) {\n const match = newlineRegex.exec(text);\n if (!match) {\n const chunks = this.processText(\n text.slice(prevIndex),\n currentModifiers,\n );\n lines.push(new AnsiLine(currentLineNumber, chunks));\n return lines;\n }\n\n const line = text.slice(prevIndex, match.index);\n prevIndex = match.index + match[0].length;\n\n const chunks = this.processText(line, currentModifiers);\n lines.push(new AnsiLine(currentLineNumber, chunks));\n\n // Modifiers that are active in the last chunk are carried over to the next line\n currentModifiers =\n chunks[chunks.length - 1].modifiers ?? currentModifiers;\n currentLineNumber += 1;\n }\n };\n\n // Processing of a one individual text chunk\n private processText = (\n fullText: string,\n modifiers: ChunkModifiers,\n ): AnsiChunk[] => {\n const chunks: AnsiChunk[] = [];\n\n let currentModifiers = modifiers;\n\n let prevIndex = 0;\n ansiRegex.lastIndex = 0;\n for (;;) {\n const match = ansiRegex.exec(fullText);\n if (!match) {\n chunks.push({\n text: fullText.slice(prevIndex),\n modifiers: currentModifiers,\n });\n return chunks;\n }\n\n const text = fullText.slice(prevIndex, match.index);\n chunks.push({ text, modifiers: currentModifiers });\n\n // For every escape code that we encounter we keep track of where the\n // next chunk of text starts, and what modifiers it has\n prevIndex = match.index + match[0].length;\n currentModifiers = this.processCode(match[0], currentModifiers);\n }\n };\n\n private processCode = (\n code: string,\n modifiers: ChunkModifiers,\n ): ChunkModifiers => {\n return codeModifiers[code]?.(modifiers) ?? modifiers;\n };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\nimport { AnsiChunk, AnsiLine, ChunkModifiers } from './AnsiProcessor';\nimport startCase from 'lodash/startCase';\nimport classnames from 'classnames';\nimport { useStyles } from './styles';\n\nexport function getModifierClasses(\n classes: ReturnType<typeof useStyles>,\n modifiers: ChunkModifiers,\n) {\n const classNames = new Array<string>();\n if (modifiers.bold) {\n classNames.push(classes.modifierBold);\n }\n if (modifiers.italic) {\n classNames.push(classes.modifierItalic);\n }\n if (modifiers.underline) {\n classNames.push(classes.modifierUnderline);\n }\n if (modifiers.foreground) {\n const key = `modifierForeground${startCase(\n modifiers.foreground,\n )}` as keyof typeof classes;\n classNames.push(classes[key]);\n }\n if (modifiers.background) {\n const key = `modifierBackground${startCase(\n modifiers.background,\n )}` as keyof typeof classes;\n classNames.push(classes[key]);\n }\n return classNames.length > 0 ? classNames.join(' ') : undefined;\n}\n\nexport function findSearchResults(text: string, searchText: string) {\n if (!searchText || !text.includes(searchText)) {\n return undefined;\n }\n const searchResults = new Array<{ start: number; end: number }>();\n let offset = 0;\n for (;;) {\n const start = text.indexOf(searchText, offset);\n if (start === -1) {\n break;\n }\n const end = start + searchText.length;\n searchResults.push({ start, end });\n offset = end;\n }\n return searchResults;\n}\n\nexport interface HighlightAnsiChunk extends AnsiChunk {\n highlight?: number;\n}\n\nexport function calculateHighlightedChunks(\n line: AnsiLine,\n searchText: string,\n): HighlightAnsiChunk[] {\n const results = findSearchResults(line.text, searchText);\n if (!results) {\n return line.chunks;\n }\n\n const chunks = new Array<HighlightAnsiChunk>();\n\n let lineOffset = 0;\n let resultIndex = 0;\n let result = results[resultIndex];\n for (const chunk of line.chunks) {\n const { text, modifiers } = chunk;\n if (!result || lineOffset + text.length < result.start) {\n chunks.push(chunk);\n lineOffset += text.length;\n continue;\n }\n\n let localOffset = 0;\n while (result) {\n const localStart = Math.max(result.start - lineOffset, 0);\n if (localStart > text.length) {\n break; // The next result is not in this chunk\n }\n\n const localEnd = Math.min(result.end - lineOffset, text.length);\n\n const hasTextBeforeResult = localStart > localOffset;\n if (hasTextBeforeResult) {\n chunks.push({ text: text.slice(localOffset, localStart), modifiers });\n }\n const hasResultText = localEnd > localStart;\n if (hasResultText) {\n chunks.push({\n modifiers,\n highlight: resultIndex,\n text: text.slice(localStart, localEnd),\n });\n }\n\n localOffset = localEnd;\n\n const foundCompleteResult = result.end - lineOffset === localEnd;\n if (foundCompleteResult) {\n resultIndex += 1;\n result = results[resultIndex];\n } else {\n break; // The rest of the result is in the following chunks\n }\n }\n\n const hasTextAfterResult = localOffset < text.length;\n if (hasTextAfterResult) {\n chunks.push({ text: text.slice(localOffset), modifiers });\n }\n\n lineOffset += text.length;\n }\n\n return chunks;\n}\n\nexport interface LogLineProps {\n line: AnsiLine;\n classes: ReturnType<typeof useStyles>;\n searchText: string;\n highlightResultIndex?: number;\n}\n\nexport function LogLine({\n line,\n classes,\n searchText,\n highlightResultIndex,\n}: LogLineProps) {\n const chunks = useMemo(\n () => calculateHighlightedChunks(line, searchText),\n [line, searchText],\n );\n\n const elements = useMemo(\n () =>\n chunks.map(({ text, modifiers, highlight }, index) => (\n // eslint-disable-next-line react/forbid-elements\n <span\n key={index}\n className={classnames(\n getModifierClasses(classes, modifiers),\n highlight !== undefined &&\n (highlight === highlightResultIndex\n ? classes.textSelectedHighlight\n : classes.textHighlight),\n )}\n >\n {text}\n </span>\n )),\n [chunks, highlightResultIndex, classes],\n );\n\n return <>{elements}</>;\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport IconButton from '@material-ui/core/IconButton';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport ChevronLeftIcon from '@material-ui/icons/ChevronLeft';\nimport ChevronRightIcon from '@material-ui/icons/ChevronRight';\nimport FilterListIcon from '@material-ui/icons/FilterList';\nimport { LogViewerSearch } from './useLogViewerSearch';\n\nexport interface LogViewerControlsProps extends LogViewerSearch {}\n\nexport function LogViewerControls(props: LogViewerControlsProps) {\n const { resultCount, resultIndexStep, toggleShouldFilter } = props;\n const resultIndex = props.resultIndex ?? 0;\n\n const handleKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n if (event.metaKey || event.ctrlKey || event.altKey) {\n toggleShouldFilter();\n } else {\n resultIndexStep(event.shiftKey);\n }\n }\n };\n\n return (\n <>\n {resultCount !== undefined && (\n <>\n <IconButton size=\"small\" onClick={() => resultIndexStep(true)}>\n <ChevronLeftIcon />\n </IconButton>\n <Typography>\n {Math.min(resultIndex + 1, resultCount)}/{resultCount}\n </Typography>\n <IconButton size=\"small\" onClick={() => resultIndexStep()}>\n <ChevronRightIcon />\n </IconButton>\n </>\n )}\n <TextField\n size=\"small\"\n variant=\"standard\"\n placeholder=\"Search\"\n value={props.searchInput}\n onKeyPress={handleKeyPress}\n onChange={e => props.setSearchInput(e.target.value)}\n />\n <IconButton size=\"small\" onClick={toggleShouldFilter}>\n {props.shouldFilter ? (\n <FilterListIcon color=\"primary\" />\n ) : (\n <FilterListIcon color=\"disabled\" />\n )}\n </IconButton>\n </>\n );\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { alpha, makeStyles } from '@material-ui/core/styles';\nimport * as colors from '@material-ui/core/colors';\n\nexport const HEADER_SIZE = 40;\n\n/** @public Class keys for overriding LogViewer styles */\nexport type LogViewerClassKey =\n | 'root'\n | 'header'\n | 'log'\n | 'line'\n | 'lineSelected'\n | 'lineCopyButton'\n | 'lineNumber'\n | 'textHighlight'\n | 'textSelectedHighlight'\n | 'modifierBold'\n | 'modifierItalic'\n | 'modifierUnderline'\n | 'modifierForegroundBlack'\n | 'modifierForegroundRed'\n | 'modifierForegroundGreen'\n | 'modifierForegroundYellow'\n | 'modifierForegroundBlue'\n | 'modifierForegroundMagenta'\n | 'modifierForegroundCyan'\n | 'modifierForegroundWhite'\n | 'modifierForegroundGrey'\n | 'modifierBackgroundBlack'\n | 'modifierBackgroundRed'\n | 'modifierBackgroundGreen'\n | 'modifierBackgroundYellow'\n | 'modifierBackgroundBlue'\n | 'modifierBackgroundMagenta'\n | 'modifierBackgroundCyan'\n | 'modifierBackgroundWhite'\n | 'modifierBackgroundGrey';\n\nexport const useStyles = makeStyles(\n theme => ({\n root: {\n background: theme.palette.background.paper,\n },\n header: {\n height: HEADER_SIZE,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'flex-end',\n },\n log: {\n fontFamily: '\"Monaco\", monospace',\n fontSize: theme.typography.pxToRem(12),\n },\n line: {\n position: 'relative',\n whiteSpace: 'pre',\n\n '&:hover': {\n background: theme.palette.action.hover,\n },\n },\n lineSelected: {\n background: theme.palette.action.selected,\n\n '&:hover': {\n background: theme.palette.action.selected,\n },\n },\n lineCopyButton: {\n position: 'absolute',\n paddingTop: 0,\n paddingBottom: 0,\n },\n lineNumber: {\n display: 'inline-block',\n textAlign: 'end',\n width: 60,\n marginRight: theme.spacing(1),\n cursor: 'pointer',\n },\n textHighlight: {\n background: alpha(theme.palette.info.main, 0.15),\n },\n textSelectedHighlight: {\n background: alpha(theme.palette.info.main, 0.4),\n },\n modifierBold: {\n fontWeight: theme.typography.fontWeightBold,\n },\n modifierItalic: {\n fontStyle: 'italic',\n },\n modifierUnderline: {\n textDecoration: 'underline',\n },\n modifierForegroundBlack: {\n color: colors.common.black,\n },\n modifierForegroundRed: {\n color: colors.red[500],\n },\n modifierForegroundGreen: {\n color: colors.green[500],\n },\n modifierForegroundYellow: {\n color: colors.yellow[500],\n },\n modifierForegroundBlue: {\n color: colors.blue[500],\n },\n modifierForegroundMagenta: {\n color: colors.purple[500],\n },\n modifierForegroundCyan: {\n color: colors.cyan[500],\n },\n modifierForegroundWhite: {\n color: colors.common.white,\n },\n modifierForegroundGrey: {\n color: colors.grey[500],\n },\n modifierBackgroundBlack: {\n background: colors.common.black,\n },\n modifierBackgroundRed: {\n background: colors.red[500],\n },\n modifierBackgroundGreen: {\n background: colors.green[500],\n },\n modifierBackgroundYellow: {\n background: colors.yellow[500],\n },\n modifierBackgroundBlue: {\n background: colors.blue[500],\n },\n modifierBackgroundMagenta: {\n background: colors.purple[500],\n },\n modifierBackgroundCyan: {\n background: colors.cyan[500],\n },\n modifierBackgroundWhite: {\n background: colors.common.white,\n },\n modifierBackgroundGrey: {\n background: colors.grey[500],\n },\n }),\n { name: 'BackstageLogViewer' },\n);\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useMemo, useState } from 'react';\nimport { useToggle } from '@react-hookz/web';\nimport { AnsiLine } from './AnsiProcessor';\n\nexport function applySearchFilter(lines: AnsiLine[], searchText: string) {\n if (!searchText) {\n return { lines };\n }\n\n const matchingLines = [];\n const searchResults = [];\n for (const line of lines) {\n if (line.text.includes(searchText)) {\n matchingLines.push(line);\n\n let offset = 0;\n let lineResultIndex = 0;\n for (;;) {\n const start = line.text.indexOf(searchText, offset);\n if (start === -1) {\n break;\n }\n searchResults.push({\n lineNumber: line.lineNumber,\n lineIndex: lineResultIndex++,\n });\n offset = start + searchText.length;\n }\n }\n }\n\n return {\n lines: matchingLines,\n results: searchResults,\n };\n}\n\nexport interface LogViewerSearch {\n lines: AnsiLine[];\n\n searchText: string;\n searchInput: string;\n setSearchInput: (searchInput: string) => void;\n\n shouldFilter: boolean;\n toggleShouldFilter: () => void;\n\n resultCount: number | undefined;\n resultIndex: number | undefined;\n resultIndexStep: (decrement?: boolean) => void;\n\n resultLine: number | undefined;\n resultLineIndex: number | undefined;\n}\n\nexport function useLogViewerSearch(lines: AnsiLine[]): LogViewerSearch {\n const [searchInput, setSearchInput] = useState('');\n const searchText = searchInput.toLocaleLowerCase('en-US');\n\n const [resultIndex, setResultIndex] = useState<number>(0);\n\n const [shouldFilter, toggleShouldFilter] = useToggle(false);\n\n const filter = useMemo(\n () => applySearchFilter(lines, searchText),\n [lines, searchText],\n );\n\n const searchResult = filter.results\n ? filter.results[Math.min(resultIndex, filter.results.length - 1)]\n : undefined;\n const resultCount = filter.results?.length;\n\n const resultIndexStep = (decrement?: boolean) => {\n if (decrement) {\n if (resultCount !== undefined) {\n const next = Math.min(resultIndex - 1, resultCount - 2);\n setResultIndex(next < 0 ? resultCount - 1 : next);\n }\n } else {\n if (resultCount !== undefined) {\n const next = resultIndex + 1;\n setResultIndex(next >= resultCount ? 0 : next);\n }\n }\n };\n\n return {\n lines: shouldFilter ? filter.lines : lines,\n searchText,\n searchInput,\n setSearchInput,\n shouldFilter,\n toggleShouldFilter,\n resultCount,\n resultIndex,\n resultIndexStep,\n resultLine: searchResult?.lineNumber,\n resultLineIndex: searchResult?.lineIndex,\n };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useEffect, useState } from 'react';\nimport useCopyToClipboard from 'react-use/lib/useCopyToClipboard';\nimport { AnsiLine } from './AnsiProcessor';\n\nexport function useLogViewerSelection(lines: AnsiLine[]) {\n const errorApi = useApi(errorApiRef);\n const [sel, setSelection] = useState<{ start: number; end: number }>();\n const start = sel ? Math.min(sel.start, sel.end) : undefined;\n const end = sel ? Math.max(sel.start, sel.end) : undefined;\n\n const [{ error }, copyToClipboard] = useCopyToClipboard();\n\n useEffect(() => {\n if (error) {\n errorApi.post(error);\n }\n }, [error, errorApi]);\n\n return {\n shouldShowButton(line: number) {\n return start === line || end === line;\n },\n isSelected(line: number) {\n if (!sel) {\n return false;\n }\n return start! <= line && line <= end!;\n },\n setSelection(line: number, add: boolean) {\n if (add) {\n setSelection(s =>\n s ? { start: s.start, end: line } : { start: line, end: line },\n );\n } else {\n setSelection(s =>\n s?.start === line && s?.end === line\n ? undefined\n : { start: line, end: line },\n );\n }\n },\n copySelection() {\n if (sel) {\n const copyText = lines\n .slice(Math.min(sel.start, sel.end) - 1, Math.max(sel.start, sel.end))\n .map(l => l.chunks.map(c => c.text).join(''))\n .join('\\n');\n copyToClipboard(copyText);\n setSelection(undefined);\n }\n },\n };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport Box from '@material-ui/core/Box';\nimport IconButton from '@material-ui/core/IconButton';\nimport CopyIcon from '@material-ui/icons/FileCopy';\nimport classnames from 'classnames';\nimport React, { useEffect, useMemo, useRef } from 'react';\nimport { useLocation } from 'react-router-dom';\nimport AutoSizer from 'react-virtualized-auto-sizer';\nimport { FixedSizeList } from 'react-window';\n\nimport { AnsiProcessor } from './AnsiProcessor';\nimport { LogLine } from './LogLine';\nimport { LogViewerControls } from './LogViewerControls';\nimport { HEADER_SIZE, useStyles } from './styles';\nimport { useLogViewerSearch } from './useLogViewerSearch';\nimport { useLogViewerSelection } from './useLogViewerSelection';\n\nexport interface RealLogViewerProps {\n text: string;\n classes?: { root?: string };\n}\n\nexport function RealLogViewer(props: RealLogViewerProps) {\n const classes = useStyles({ classes: props.classes });\n const listRef = useRef<FixedSizeList | null>(null);\n\n // The processor keeps state that optimizes appending to the text\n const processor = useMemo(() => new AnsiProcessor(), []);\n const lines = processor.process(props.text);\n\n const search = useLogViewerSearch(lines);\n const selection = useLogViewerSelection(lines);\n const location = useLocation();\n\n useEffect(() => {\n if (search.resultLine !== undefined && listRef.current) {\n listRef.current.scrollToItem(search.resultLine - 1, 'center');\n }\n }, [search.resultLine]);\n\n useEffect(() => {\n if (location.hash) {\n // #line-6 -> 6\n const line = parseInt(location.hash.replace(/\\D/g, ''), 10);\n selection.setSelection(line, false);\n }\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleSelectLine = (\n line: number,\n event: { shiftKey: boolean; preventDefault: () => void },\n ) => {\n selection.setSelection(line, event.shiftKey);\n };\n\n return (\n <AutoSizer>\n {({ height, width }) => (\n <Box style={{ width, height }} className={classes.root}>\n <Box className={classes.header}>\n <LogViewerControls {...search} />\n </Box>\n <FixedSizeList\n ref={listRef}\n className={classes.log}\n height={height - HEADER_SIZE}\n width={width}\n itemData={search.lines}\n itemSize={20}\n itemCount={search.lines.length}\n >\n {({ index, style, data }) => {\n const line = data[index];\n const { lineNumber } = line;\n return (\n <Box\n style={{ ...style }}\n className={classnames(classes.line, {\n [classes.lineSelected]: selection.isSelected(lineNumber),\n })}\n >\n {selection.shouldShowButton(lineNumber) && (\n <IconButton\n data-testid=\"copy-button\"\n size=\"small\"\n className={classes.lineCopyButton}\n onClick={() => selection.copySelection()}\n >\n <CopyIcon fontSize=\"inherit\" />\n </IconButton>\n )}\n <a\n role=\"row\"\n target=\"_self\"\n href={`#line-${lineNumber}`}\n className={classes.lineNumber}\n onClick={event => handleSelectLine(lineNumber, event)}\n onKeyPress={event => handleSelectLine(lineNumber, event)}\n >\n {lineNumber}\n </a>\n <LogLine\n line={line}\n classes={classes}\n searchText={search.searchText}\n highlightResultIndex={\n search.resultLine === lineNumber\n ? search.resultLineIndex\n : undefined\n }\n />\n </Box>\n );\n }}\n </FixedSizeList>\n </Box>\n )}\n </AutoSizer>\n );\n}\n"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/AnsiProcessor.ts","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/LogLine.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/LogViewerControls.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/styles.ts","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/useLogViewerSearch.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/useLogViewerSelection.tsx","webpack://techdocs-cli-embedded-app/../core-components/src/components/LogViewer/RealLogViewer.tsx"],"names":["ansiRegex","ansiRegexMaker","newlineRegex","codeModifiers","Object","fromEntries","entries","m","bold","italic","underline","_","foreground","background","map","code","modifier","AnsiLine","lastChunk","chunks","length","replaceLastChunk","newChunks","splice","text","c","join","toLocaleLowerCase","constructor","lineNumber","AnsiProcessor","process","lines","startsWith","newLines","lastLineIndex","lastLine","processLines","slice","modifiers","push","startingLineNumber","currentModifiers","currentLineNumber","prevIndex","lastIndex","match","exec","processText","line","index","fullText","processCode","getModifierClasses","classes","classNames","Array","modifierBold","modifierItalic","modifierUnderline","key","startCase","undefined","findSearchResults","searchText","includes","searchResults","offset","start","indexOf","end","calculateHighlightedChunks","results","lineOffset","resultIndex","result","chunk","localOffset","localStart","Math","max","localEnd","min","highlight","LogLine","highlightResultIndex","useMemo","elements","span","className","classnames","textSelectedHighlight","textHighlight","LogViewerControls","props","resultCount","resultIndexStep","toggleShouldFilter","handleKeyPress","event","metaKey","ctrlKey","altKey","shiftKey","IconButton","size","onClick","ChevronLeftIcon","Typography","ChevronRightIcon","TextField","variant","placeholder","value","searchInput","onKeyPress","onChange","e","setSearchInput","target","shouldFilter","FilterListIcon","color","HEADER_SIZE","useStyles","makeStyles","theme","root","palette","paper","header","height","display","alignItems","justifyContent","log","fontFamily","fontSize","typography","pxToRem","position","whiteSpace","action","hover","lineSelected","selected","lineCopyButton","paddingTop","paddingBottom","textAlign","width","marginRight","spacing","cursor","alpha","info","main","fontWeight","fontWeightBold","fontStyle","textDecoration","modifierForegroundBlack","colors","modifierForegroundRed","modifierForegroundGreen","modifierForegroundYellow","modifierForegroundBlue","modifierForegroundMagenta","modifierForegroundCyan","modifierForegroundWhite","modifierForegroundGrey","modifierBackgroundBlack","modifierBackgroundRed","modifierBackgroundGreen","modifierBackgroundYellow","modifierBackgroundBlue","modifierBackgroundMagenta","modifierBackgroundCyan","modifierBackgroundWhite","modifierBackgroundGrey","name","applySearchFilter","matchingLines","lineResultIndex","lineIndex","useLogViewerSearch","filter","useState","setResultIndex","useToggle","searchResult","decrement","next","resultLine","resultLineIndex","useLogViewerSelection","errorApi","useApi","errorApiRef","sel","setSelection","error","copyToClipboard","useCopyToClipboard","useEffect","post","shouldShowButton","isSelected","add","s","copySelection","copyText","l","RealLogViewer","listRef","useRef","search","selection","location","useLocation","current","scrollToItem","hash","parseInt","replace","handleSelectLine","AutoSizer","Box","style","FixedSizeList","ref","itemData","itemSize","itemCount","data","data-testid","CopyIcon","a","role","href"],"mappings":"iUAkBA,MAAMA,G,EAAYC,KAAe,EAC3BC,EAAe,SAGfC,EAAgBC,OAAOC,YAC3BD,OAAOE,QAAQ,CACb,EAAGC,IAAM,CAAE,GAAGA,EAAGC,KAAM,EAAK,GAC5B,EAAGD,IAAM,CAAE,GAAGA,EAAGE,OAAQ,EAAK,GAC9B,EAAGF,IAAM,CAAE,GAAGA,EAAGG,UAAW,EAAK,GACjC,GAAI,CAAC,CAAEF,KAAMG,KAAMJ,CAAE,IAAMA,EAC3B,GAAI,CAAC,CAAEE,OAAQE,KAAMJ,CAAE,IAAMA,EAC7B,GAAI,CAAC,CAAEG,UAAWC,KAAMJ,CAAE,IAAMA,EAChC,GAAIA,IAAM,CAAE,GAAGA,EAAGK,WAAY,OAAQ,GACtC,GAAIL,IAAM,CAAE,GAAGA,EAAGK,WAAY,KAAM,GACpC,GAAIL,IAAM,CAAE,GAAGA,EAAGK,WAAY,OAAQ,GACtC,GAAIL,IAAM,CAAE,GAAGA,EAAGK,WAAY,QAAS,GACvC,GAAIL,IAAM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C,CAAE8B,QAAOkL,QAAOM,MAAK,IAAM,CAC3B,MAAMzL,EAAOyL,EAAKxL,GACZ,CAAErB,YAAW,EAAIoB,EACvB,O,EACE,QAACkL,IAAGA,CACFC,MAAO,CAAE,GAAGA,CAAM,EAClB3I,UAAWC,IAAWpC,EAAQL,KAAM,CAClC,CAACK,EAAQ0F,cAAeyE,EAAUV,WAAWlL,CAAU,CACzD,CAAC,E,UAEA4L,EAAUX,iBAAiBjL,CAAU,I,EACpC,OAAC2E,IAAUA,CACTmI,cAAY,cACZlI,KAAK,QACLhB,UAAWnC,EAAQ4F,eACnBxC,QAAS,IAAM+G,EAAUP,cAAc,E,YAEvC,OAAC0B,IAAQA,CAACnG,SAAS,S,QAGvB,OAACoG,KACCC,KAAK,MACLvH,OAAO,QACPwH,KAAM,SAASlN,IACf4D,UAAWnC,EAAQzB,WACnB6E,QAASP,GAAS8H,EAAiBpM,EAAYsE,CAAK,EACpDgB,WAAYhB,GAAS8H,EAAiBpM,EAAYsE,CAAK,E,SAEtDtE,C,MAEH,OAACuD,EAAOA,CACNnC,KAAMA,EACNK,QAASA,EACTU,WAAYwJ,EAAOxJ,WACnBqB,qBACEmI,EAAOvB,aAAepK,EAClB2L,EAAOtB,gBACPpI,M,KAKd,C,OAMZ,C","file":"static/6051.66d9ff08.chunk.js","sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport ansiRegexMaker from 'ansi-regex';\n\nconst ansiRegex = ansiRegexMaker();\nconst newlineRegex = /\\n\\r?/g;\n\n// A mapping of how each escape code changes the modifiers\nconst codeModifiers = Object.fromEntries(\n Object.entries({\n 1: m => ({ ...m, bold: true }),\n 3: m => ({ ...m, italic: true }),\n 4: m => ({ ...m, underline: true }),\n 22: ({ bold: _, ...m }) => m,\n 23: ({ italic: _, ...m }) => m,\n 24: ({ underline: _, ...m }) => m,\n 30: m => ({ ...m, foreground: 'black' }),\n 31: m => ({ ...m, foreground: 'red' }),\n 32: m => ({ ...m, foreground: 'green' }),\n 33: m => ({ ...m, foreground: 'yellow' }),\n 34: m => ({ ...m, foreground: 'blue' }),\n 35: m => ({ ...m, foreground: 'magenta' }),\n 36: m => ({ ...m, foreground: 'cyan' }),\n 37: m => ({ ...m, foreground: 'white' }),\n 39: ({ foreground: _, ...m }) => m,\n 90: m => ({ ...m, foreground: 'grey' }),\n 40: m => ({ ...m, background: 'black' }),\n 41: m => ({ ...m, background: 'red' }),\n 42: m => ({ ...m, background: 'green' }),\n 43: m => ({ ...m, background: 'yellow' }),\n 44: m => ({ ...m, background: 'blue' }),\n 45: m => ({ ...m, background: 'magenta' }),\n 46: m => ({ ...m, background: 'cyan' }),\n 47: m => ({ ...m, background: 'white' }),\n 49: ({ background: _, ...m }) => m,\n } as Record<string, (m: ChunkModifiers) => ChunkModifiers>).map(\n ([code, modifier]) => [`\\x1b[${code}m`, modifier],\n ),\n);\n\nexport type AnsiColor =\n | 'black'\n | 'red'\n | 'green'\n | 'yellow'\n | 'blue'\n | 'magenta'\n | 'cyan'\n | 'white'\n | 'grey';\n\nexport interface ChunkModifiers {\n foreground?: AnsiColor;\n background?: AnsiColor;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n}\n\nexport interface AnsiChunk {\n text: string;\n modifiers: ChunkModifiers;\n}\n\nexport class AnsiLine {\n text: string;\n\n constructor(\n readonly lineNumber: number = 1,\n readonly chunks: AnsiChunk[] = [],\n ) {\n this.text = chunks\n .map(c => c.text)\n .join('')\n .toLocaleLowerCase('en-US');\n }\n\n lastChunk(): AnsiChunk | undefined {\n return this.chunks[this.chunks.length - 1];\n }\n\n replaceLastChunk(newChunks?: AnsiChunk[]) {\n if (newChunks) {\n this.chunks.splice(this.chunks.length - 1, 1, ...newChunks);\n this.text = this.chunks\n .map(c => c.text)\n .join('')\n .toLocaleLowerCase('en-US');\n }\n }\n}\n\nexport class AnsiProcessor {\n private text: string = '';\n private lines: AnsiLine[] = [];\n\n /**\n * Processes a chunk of text while keeping internal state that optimizes\n * subsequent processing that appends to the text.\n */\n process(text: string): AnsiLine[] {\n if (this.text === text) {\n return this.lines;\n }\n\n if (text.startsWith(this.text)) {\n const lastLineIndex = this.lines.length > 0 ? this.lines.length - 1 : 0;\n const lastLine = this.lines[lastLineIndex] ?? new AnsiLine();\n const lastChunk = lastLine.lastChunk();\n\n const newLines = this.processLines(\n (lastChunk?.text ?? '') + text.slice(this.text.length),\n lastChunk?.modifiers,\n lastLine?.lineNumber,\n );\n lastLine.replaceLastChunk(newLines[0]?.chunks);\n\n this.lines[lastLineIndex] = lastLine;\n this.lines.push(...newLines.slice(1));\n } else {\n this.lines = this.processLines(text);\n }\n this.text = text;\n\n return this.lines;\n }\n\n // Split a chunk of text up into lines and process each line individually\n private processLines = (\n text: string,\n modifiers: ChunkModifiers = {},\n startingLineNumber: number = 1,\n ): AnsiLine[] => {\n const lines: AnsiLine[] = [];\n\n let currentModifiers = modifiers;\n let currentLineNumber = startingLineNumber;\n\n let prevIndex = 0;\n newlineRegex.lastIndex = 0;\n for (;;) {\n const match = newlineRegex.exec(text);\n if (!match) {\n const chunks = this.processText(\n text.slice(prevIndex),\n currentModifiers,\n );\n lines.push(new AnsiLine(currentLineNumber, chunks));\n return lines;\n }\n\n const line = text.slice(prevIndex, match.index);\n prevIndex = match.index + match[0].length;\n\n const chunks = this.processText(line, currentModifiers);\n lines.push(new AnsiLine(currentLineNumber, chunks));\n\n // Modifiers that are active in the last chunk are carried over to the next line\n currentModifiers =\n chunks[chunks.length - 1].modifiers ?? currentModifiers;\n currentLineNumber += 1;\n }\n };\n\n // Processing of a one individual text chunk\n private processText = (\n fullText: string,\n modifiers: ChunkModifiers,\n ): AnsiChunk[] => {\n const chunks: AnsiChunk[] = [];\n\n let currentModifiers = modifiers;\n\n let prevIndex = 0;\n ansiRegex.lastIndex = 0;\n for (;;) {\n const match = ansiRegex.exec(fullText);\n if (!match) {\n chunks.push({\n text: fullText.slice(prevIndex),\n modifiers: currentModifiers,\n });\n return chunks;\n }\n\n const text = fullText.slice(prevIndex, match.index);\n chunks.push({ text, modifiers: currentModifiers });\n\n // For every escape code that we encounter we keep track of where the\n // next chunk of text starts, and what modifiers it has\n prevIndex = match.index + match[0].length;\n currentModifiers = this.processCode(match[0], currentModifiers);\n }\n };\n\n private processCode = (\n code: string,\n modifiers: ChunkModifiers,\n ): ChunkModifiers => {\n return codeModifiers[code]?.(modifiers) ?? modifiers;\n };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\nimport { AnsiChunk, AnsiLine, ChunkModifiers } from './AnsiProcessor';\nimport startCase from 'lodash/startCase';\nimport classnames from 'classnames';\nimport { useStyles } from './styles';\n\nexport function getModifierClasses(\n classes: ReturnType<typeof useStyles>,\n modifiers: ChunkModifiers,\n) {\n const classNames = new Array<string>();\n if (modifiers.bold) {\n classNames.push(classes.modifierBold);\n }\n if (modifiers.italic) {\n classNames.push(classes.modifierItalic);\n }\n if (modifiers.underline) {\n classNames.push(classes.modifierUnderline);\n }\n if (modifiers.foreground) {\n const key = `modifierForeground${startCase(\n modifiers.foreground,\n )}` as keyof typeof classes;\n classNames.push(classes[key]);\n }\n if (modifiers.background) {\n const key = `modifierBackground${startCase(\n modifiers.background,\n )}` as keyof typeof classes;\n classNames.push(classes[key]);\n }\n return classNames.length > 0 ? classNames.join(' ') : undefined;\n}\n\nexport function findSearchResults(text: string, searchText: string) {\n if (!searchText || !text.includes(searchText)) {\n return undefined;\n }\n const searchResults = new Array<{ start: number; end: number }>();\n let offset = 0;\n for (;;) {\n const start = text.indexOf(searchText, offset);\n if (start === -1) {\n break;\n }\n const end = start + searchText.length;\n searchResults.push({ start, end });\n offset = end;\n }\n return searchResults;\n}\n\nexport interface HighlightAnsiChunk extends AnsiChunk {\n highlight?: number;\n}\n\nexport function calculateHighlightedChunks(\n line: AnsiLine,\n searchText: string,\n): HighlightAnsiChunk[] {\n const results = findSearchResults(line.text, searchText);\n if (!results) {\n return line.chunks;\n }\n\n const chunks = new Array<HighlightAnsiChunk>();\n\n let lineOffset = 0;\n let resultIndex = 0;\n let result = results[resultIndex];\n for (const chunk of line.chunks) {\n const { text, modifiers } = chunk;\n if (!result || lineOffset + text.length < result.start) {\n chunks.push(chunk);\n lineOffset += text.length;\n continue;\n }\n\n let localOffset = 0;\n while (result) {\n const localStart = Math.max(result.start - lineOffset, 0);\n if (localStart > text.length) {\n break; // The next result is not in this chunk\n }\n\n const localEnd = Math.min(result.end - lineOffset, text.length);\n\n const hasTextBeforeResult = localStart > localOffset;\n if (hasTextBeforeResult) {\n chunks.push({ text: text.slice(localOffset, localStart), modifiers });\n }\n const hasResultText = localEnd > localStart;\n if (hasResultText) {\n chunks.push({\n modifiers,\n highlight: resultIndex,\n text: text.slice(localStart, localEnd),\n });\n }\n\n localOffset = localEnd;\n\n const foundCompleteResult = result.end - lineOffset === localEnd;\n if (foundCompleteResult) {\n resultIndex += 1;\n result = results[resultIndex];\n } else {\n break; // The rest of the result is in the following chunks\n }\n }\n\n const hasTextAfterResult = localOffset < text.length;\n if (hasTextAfterResult) {\n chunks.push({ text: text.slice(localOffset), modifiers });\n }\n\n lineOffset += text.length;\n }\n\n return chunks;\n}\n\nexport interface LogLineProps {\n line: AnsiLine;\n classes: ReturnType<typeof useStyles>;\n searchText: string;\n highlightResultIndex?: number;\n}\n\nexport function LogLine({\n line,\n classes,\n searchText,\n highlightResultIndex,\n}: LogLineProps) {\n const chunks = useMemo(\n () => calculateHighlightedChunks(line, searchText),\n [line, searchText],\n );\n\n const elements = useMemo(\n () =>\n chunks.map(({ text, modifiers, highlight }, index) => (\n // eslint-disable-next-line react/forbid-elements\n <span\n key={index}\n className={classnames(\n getModifierClasses(classes, modifiers),\n highlight !== undefined &&\n (highlight === highlightResultIndex\n ? classes.textSelectedHighlight\n : classes.textHighlight),\n )}\n >\n {text}\n </span>\n )),\n [chunks, highlightResultIndex, classes],\n );\n\n return <>{elements}</>;\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport IconButton from '@material-ui/core/IconButton';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport ChevronLeftIcon from '@material-ui/icons/ChevronLeft';\nimport ChevronRightIcon from '@material-ui/icons/ChevronRight';\nimport FilterListIcon from '@material-ui/icons/FilterList';\nimport { LogViewerSearch } from './useLogViewerSearch';\n\nexport interface LogViewerControlsProps extends LogViewerSearch {}\n\nexport function LogViewerControls(props: LogViewerControlsProps) {\n const { resultCount, resultIndexStep, toggleShouldFilter } = props;\n const resultIndex = props.resultIndex ?? 0;\n\n const handleKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n if (event.metaKey || event.ctrlKey || event.altKey) {\n toggleShouldFilter();\n } else {\n resultIndexStep(event.shiftKey);\n }\n }\n };\n\n return (\n <>\n {resultCount !== undefined && (\n <>\n <IconButton size=\"small\" onClick={() => resultIndexStep(true)}>\n <ChevronLeftIcon />\n </IconButton>\n <Typography>\n {Math.min(resultIndex + 1, resultCount)}/{resultCount}\n </Typography>\n <IconButton size=\"small\" onClick={() => resultIndexStep()}>\n <ChevronRightIcon />\n </IconButton>\n </>\n )}\n <TextField\n size=\"small\"\n variant=\"standard\"\n placeholder=\"Search\"\n value={props.searchInput}\n onKeyPress={handleKeyPress}\n onChange={e => props.setSearchInput(e.target.value)}\n />\n <IconButton size=\"small\" onClick={toggleShouldFilter}>\n {props.shouldFilter ? (\n <FilterListIcon color=\"primary\" />\n ) : (\n <FilterListIcon color=\"disabled\" />\n )}\n </IconButton>\n </>\n );\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { alpha, makeStyles } from '@material-ui/core/styles';\nimport * as colors from '@material-ui/core/colors';\n\nexport const HEADER_SIZE = 40;\n\n/** @public Class keys for overriding LogViewer styles */\nexport type LogViewerClassKey =\n | 'root'\n | 'header'\n | 'log'\n | 'line'\n | 'lineSelected'\n | 'lineCopyButton'\n | 'lineNumber'\n | 'textHighlight'\n | 'textSelectedHighlight'\n | 'modifierBold'\n | 'modifierItalic'\n | 'modifierUnderline'\n | 'modifierForegroundBlack'\n | 'modifierForegroundRed'\n | 'modifierForegroundGreen'\n | 'modifierForegroundYellow'\n | 'modifierForegroundBlue'\n | 'modifierForegroundMagenta'\n | 'modifierForegroundCyan'\n | 'modifierForegroundWhite'\n | 'modifierForegroundGrey'\n | 'modifierBackgroundBlack'\n | 'modifierBackgroundRed'\n | 'modifierBackgroundGreen'\n | 'modifierBackgroundYellow'\n | 'modifierBackgroundBlue'\n | 'modifierBackgroundMagenta'\n | 'modifierBackgroundCyan'\n | 'modifierBackgroundWhite'\n | 'modifierBackgroundGrey';\n\nexport const useStyles = makeStyles(\n theme => ({\n root: {\n background: theme.palette.background.paper,\n },\n header: {\n height: HEADER_SIZE,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'flex-end',\n },\n log: {\n fontFamily: '\"Monaco\", monospace',\n fontSize: theme.typography.pxToRem(12),\n },\n line: {\n position: 'relative',\n whiteSpace: 'pre',\n\n '&:hover': {\n background: theme.palette.action.hover,\n },\n },\n lineSelected: {\n background: theme.palette.action.selected,\n\n '&:hover': {\n background: theme.palette.action.selected,\n },\n },\n lineCopyButton: {\n position: 'absolute',\n paddingTop: 0,\n paddingBottom: 0,\n },\n lineNumber: {\n display: 'inline-block',\n textAlign: 'end',\n width: 60,\n marginRight: theme.spacing(1),\n cursor: 'pointer',\n },\n textHighlight: {\n background: alpha(theme.palette.info.main, 0.15),\n },\n textSelectedHighlight: {\n background: alpha(theme.palette.info.main, 0.4),\n },\n modifierBold: {\n fontWeight: theme.typography.fontWeightBold,\n },\n modifierItalic: {\n fontStyle: 'italic',\n },\n modifierUnderline: {\n textDecoration: 'underline',\n },\n modifierForegroundBlack: {\n color: colors.common.black,\n },\n modifierForegroundRed: {\n color: colors.red[500],\n },\n modifierForegroundGreen: {\n color: colors.green[500],\n },\n modifierForegroundYellow: {\n color: colors.yellow[500],\n },\n modifierForegroundBlue: {\n color: colors.blue[500],\n },\n modifierForegroundMagenta: {\n color: colors.purple[500],\n },\n modifierForegroundCyan: {\n color: colors.cyan[500],\n },\n modifierForegroundWhite: {\n color: colors.common.white,\n },\n modifierForegroundGrey: {\n color: colors.grey[500],\n },\n modifierBackgroundBlack: {\n background: colors.common.black,\n },\n modifierBackgroundRed: {\n background: colors.red[500],\n },\n modifierBackgroundGreen: {\n background: colors.green[500],\n },\n modifierBackgroundYellow: {\n background: colors.yellow[500],\n },\n modifierBackgroundBlue: {\n background: colors.blue[500],\n },\n modifierBackgroundMagenta: {\n background: colors.purple[500],\n },\n modifierBackgroundCyan: {\n background: colors.cyan[500],\n },\n modifierBackgroundWhite: {\n background: colors.common.white,\n },\n modifierBackgroundGrey: {\n background: colors.grey[500],\n },\n }),\n { name: 'BackstageLogViewer' },\n);\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useMemo, useState } from 'react';\nimport { useToggle } from '@react-hookz/web';\nimport { AnsiLine } from './AnsiProcessor';\n\nexport function applySearchFilter(lines: AnsiLine[], searchText: string) {\n if (!searchText) {\n return { lines };\n }\n\n const matchingLines = [];\n const searchResults = [];\n for (const line of lines) {\n if (line.text.includes(searchText)) {\n matchingLines.push(line);\n\n let offset = 0;\n let lineResultIndex = 0;\n for (;;) {\n const start = line.text.indexOf(searchText, offset);\n if (start === -1) {\n break;\n }\n searchResults.push({\n lineNumber: line.lineNumber,\n lineIndex: lineResultIndex++,\n });\n offset = start + searchText.length;\n }\n }\n }\n\n return {\n lines: matchingLines,\n results: searchResults,\n };\n}\n\nexport interface LogViewerSearch {\n lines: AnsiLine[];\n\n searchText: string;\n searchInput: string;\n setSearchInput: (searchInput: string) => void;\n\n shouldFilter: boolean;\n toggleShouldFilter: () => void;\n\n resultCount: number | undefined;\n resultIndex: number | undefined;\n resultIndexStep: (decrement?: boolean) => void;\n\n resultLine: number | undefined;\n resultLineIndex: number | undefined;\n}\n\nexport function useLogViewerSearch(lines: AnsiLine[]): LogViewerSearch {\n const [searchInput, setSearchInput] = useState('');\n const searchText = searchInput.toLocaleLowerCase('en-US');\n\n const [resultIndex, setResultIndex] = useState<number>(0);\n\n const [shouldFilter, toggleShouldFilter] = useToggle(false);\n\n const filter = useMemo(\n () => applySearchFilter(lines, searchText),\n [lines, searchText],\n );\n\n const searchResult = filter.results\n ? filter.results[Math.min(resultIndex, filter.results.length - 1)]\n : undefined;\n const resultCount = filter.results?.length;\n\n const resultIndexStep = (decrement?: boolean) => {\n if (decrement) {\n if (resultCount !== undefined) {\n const next = Math.min(resultIndex - 1, resultCount - 2);\n setResultIndex(next < 0 ? resultCount - 1 : next);\n }\n } else {\n if (resultCount !== undefined) {\n const next = resultIndex + 1;\n setResultIndex(next >= resultCount ? 0 : next);\n }\n }\n };\n\n return {\n lines: shouldFilter ? filter.lines : lines,\n searchText,\n searchInput,\n setSearchInput,\n shouldFilter,\n toggleShouldFilter,\n resultCount,\n resultIndex,\n resultIndexStep,\n resultLine: searchResult?.lineNumber,\n resultLineIndex: searchResult?.lineIndex,\n };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useEffect, useState } from 'react';\nimport useCopyToClipboard from 'react-use/lib/useCopyToClipboard';\nimport { AnsiLine } from './AnsiProcessor';\n\nexport function useLogViewerSelection(lines: AnsiLine[]) {\n const errorApi = useApi(errorApiRef);\n const [sel, setSelection] = useState<{ start: number; end: number }>();\n const start = sel ? Math.min(sel.start, sel.end) : undefined;\n const end = sel ? Math.max(sel.start, sel.end) : undefined;\n\n const [{ error }, copyToClipboard] = useCopyToClipboard();\n\n useEffect(() => {\n if (error) {\n errorApi.post(error);\n }\n }, [error, errorApi]);\n\n return {\n shouldShowButton(line: number) {\n return start === line || end === line;\n },\n isSelected(line: number) {\n if (!sel) {\n return false;\n }\n return start! <= line && line <= end!;\n },\n setSelection(line: number, add: boolean) {\n if (add) {\n setSelection(s =>\n s ? { start: s.start, end: line } : { start: line, end: line },\n );\n } else {\n setSelection(s =>\n s?.start === line && s?.end === line\n ? undefined\n : { start: line, end: line },\n );\n }\n },\n copySelection() {\n if (sel) {\n const copyText = lines\n .slice(Math.min(sel.start, sel.end) - 1, Math.max(sel.start, sel.end))\n .map(l => l.chunks.map(c => c.text).join(''))\n .join('\\n');\n copyToClipboard(copyText);\n setSelection(undefined);\n }\n },\n };\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport Box from '@material-ui/core/Box';\nimport IconButton from '@material-ui/core/IconButton';\nimport CopyIcon from '@material-ui/icons/FileCopy';\nimport classnames from 'classnames';\nimport React, { useEffect, useMemo, useRef } from 'react';\nimport { useLocation } from 'react-router-dom';\nimport AutoSizer from 'react-virtualized-auto-sizer';\nimport { FixedSizeList } from 'react-window';\n\nimport { AnsiProcessor } from './AnsiProcessor';\nimport { LogLine } from './LogLine';\nimport { LogViewerControls } from './LogViewerControls';\nimport { HEADER_SIZE, useStyles } from './styles';\nimport { useLogViewerSearch } from './useLogViewerSearch';\nimport { useLogViewerSelection } from './useLogViewerSelection';\n\nexport interface RealLogViewerProps {\n text: string;\n classes?: { root?: string };\n}\n\nexport function RealLogViewer(props: RealLogViewerProps) {\n const classes = useStyles({ classes: props.classes });\n const listRef = useRef<FixedSizeList | null>(null);\n\n // The processor keeps state that optimizes appending to the text\n const processor = useMemo(() => new AnsiProcessor(), []);\n const lines = processor.process(props.text);\n\n const search = useLogViewerSearch(lines);\n const selection = useLogViewerSelection(lines);\n const location = useLocation();\n\n useEffect(() => {\n if (search.resultLine !== undefined && listRef.current) {\n listRef.current.scrollToItem(search.resultLine - 1, 'center');\n }\n }, [search.resultLine]);\n\n useEffect(() => {\n if (location.hash) {\n // #line-6 -> 6\n const line = parseInt(location.hash.replace(/\\D/g, ''), 10);\n selection.setSelection(line, false);\n }\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleSelectLine = (\n line: number,\n event: { shiftKey: boolean; preventDefault: () => void },\n ) => {\n selection.setSelection(line, event.shiftKey);\n };\n\n return (\n <AutoSizer>\n {({ height, width }) => (\n <Box style={{ width, height }} className={classes.root}>\n <Box className={classes.header}>\n <LogViewerControls {...search} />\n </Box>\n <FixedSizeList\n ref={listRef}\n className={classes.log}\n height={height - HEADER_SIZE}\n width={width}\n itemData={search.lines}\n itemSize={20}\n itemCount={search.lines.length}\n >\n {({ index, style, data }) => {\n const line = data[index];\n const { lineNumber } = line;\n return (\n <Box\n style={{ ...style }}\n className={classnames(classes.line, {\n [classes.lineSelected]: selection.isSelected(lineNumber),\n })}\n >\n {selection.shouldShowButton(lineNumber) && (\n <IconButton\n data-testid=\"copy-button\"\n size=\"small\"\n className={classes.lineCopyButton}\n onClick={() => selection.copySelection()}\n >\n <CopyIcon fontSize=\"inherit\" />\n </IconButton>\n )}\n <a\n role=\"row\"\n target=\"_self\"\n href={`#line-${lineNumber}`}\n className={classes.lineNumber}\n onClick={event => handleSelectLine(lineNumber, event)}\n onKeyPress={event => handleSelectLine(lineNumber, event)}\n >\n {lineNumber}\n </a>\n <LogLine\n line={line}\n classes={classes}\n searchText={search.searchText}\n highlightResultIndex={\n search.resultLine === lineNumber\n ? search.resultLineIndex\n : undefined\n }\n />\n </Box>\n );\n }}\n </FixedSizeList>\n </Box>\n )}\n </AutoSizer>\n );\n}\n"],"sourceRoot":""}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[7560],{27560:function(g,D,e){e.r(D),e.d(D,{TechDocsCustomHome:function(){return v}});var t=e(52322),C=e(2784),p=e(64279),O=e(79692),d=e(56941),j=e(68435),x=e(85478),_=e(42081),n=e(23196),M=e(25248);const T={DocsTable:j.H,DocsCardGrid:x.f},f=({config:s,entities:i,index:r})=>{const E=(0,O.Z)({panelContainer:{marginBottom:"2rem",...s.panelCSS?s.panelCSS:{}}})(),{loading:c,isOwnedEntity:u}=(0,d.ZW)(),l=T[s.panelType],h=i.filter(a=>s.filterPredicate==="ownedByUser"?c?!1:u(a):typeof s.filterPredicate=="function"&&s.filterPredicate(a));return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.yW,{title:s.title,description:s.description,children:r===0?(0,t.jsx)(n.qt,{children:"Discover documentation in your ecosystem."}):null}),(0,t.jsx)("div",{className:E.panelContainer,children:(0,t.jsx)(l,{"data-testid":"techdocs-custom-panel",entities:h})})]})},v=s=>{const{tabsConfig:i}=s,[r,P]=(0,C.useState)(0),E=(0,M.h_)(d.Ah),{value:c,loading:u,error:l}=(0,p.default)(async()=>(await E.getEntities({filter:{"metadata.annotations.backstage.io/techdocs-ref":d.n3},fields:["apiVersion","kind","metadata","relations","spec.owner","spec.type"]})).items.filter(o=>{var m;return!!(!((m=o.metadata.annotations)===null||m===void 0)&&m["backstage.io/techdocs-ref"])})),h=i[r];return u?(0,t.jsx)(_.j,{children:(0,t.jsx)(n.VY,{children:(0,t.jsx)(n.Ex,{})})}):l?(0,t.jsx)(_.j,{children:(0,t.jsx)(n.VY,{children:(0,t.jsx)(n.GB,{severity:"error",title:"Could not load available documentation.",children:(0,t.jsx)(n.Oi,{language:"text",text:l.toString()})})})}):(0,t.jsxs)(_.j,{children:[(0,t.jsx)(n.aR,{selectedIndex:r,onChange:a=>P(a),tabs:i.map(({label:a},o)=>({id:o.toString(),label:a}))}),(0,t.jsx)(n.VY,{"data-testid":"techdocs-content",children:h.panels.map((a,o)=>(0,t.jsx)(f,{config:a,entities:c||[],index:o},o))})]})}}}]);})();
|
|
2
2
|
|
|
3
|
-
//# sourceMappingURL=7560.
|
|
3
|
+
//# sourceMappingURL=7560.3487acce.chunk.js.map
|