@techdocs/cli 0.0.0-nightly-20220406023303 → 0.0.0-nightly-20220407023218

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @techdocs/cli
2
2
 
3
- ## 0.0.0-nightly-20220406023303
3
+ ## 0.0.0-nightly-20220407023218
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -15,10 +15,12 @@
15
15
 
16
16
  ### Patch Changes
17
17
 
18
+ - 230ad0826f: Bump to using `@types/node` v16
19
+ - eb470ea54c: Adds a new flag to override the entrypoint when using a custom docker image. It could be used to reuse existing images with different entrypoints.
18
20
  - Updated dependencies
19
- - @backstage/catalog-model@0.0.0-nightly-20220406023303
20
- - @backstage/backend-common@0.0.0-nightly-20220406023303
21
- - @backstage/plugin-techdocs-node@0.0.0-nightly-20220406023303
21
+ - @backstage/catalog-model@0.0.0-nightly-20220407023218
22
+ - @backstage/backend-common@0.0.0-nightly-20220407023218
23
+ - @backstage/plugin-techdocs-node@0.0.0-nightly-20220407023218
22
24
 
23
25
  ## 1.0.1-next.0
24
26
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  var openBrowser = require('react-dev-utils/openBrowser');
4
4
  var utility = require('./utility-51f4a306.cjs.js');
5
- var mkdocsServer = require('./mkdocsServer-758a3ae9.cjs.js');
5
+ var mkdocsServer = require('./mkdocsServer-0af6527d.cjs.js');
6
6
  require('winston');
7
7
  require('child_process');
8
8
 
@@ -36,6 +36,7 @@ Starting mkdocs server on ${localAddr}
36
36
  const childProcess = await mkdocsServer.runMkdocsServer({
37
37
  port: cmd.port,
38
38
  dockerImage: cmd.dockerImage,
39
+ dockerEntrypoint: cmd.dockerEntrypoint,
39
40
  useDocker: cmd.docker,
40
41
  stdoutLogFunc: logFunc,
41
42
  stderrLogFunc: logFunc
@@ -44,4 +45,4 @@ Starting mkdocs server on ${localAddr}
44
45
  }
45
46
 
46
47
  exports["default"] = serveMkdocs;
47
- //# sourceMappingURL=mkdocs-30f530ff.cjs.js.map
48
+ //# sourceMappingURL=mkdocs-7c045a2a.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mkdocs-30f530ff.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 { Command } 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';\n\nexport default async function serveMkdocs(cmd: Command) {\n const logger = createLogger({ verbose: cmd.verbose });\n\n const dockerAddr = `http://0.0.0.0:${cmd.port}`;\n const localAddr = `http://127.0.0.1:${cmd.port}`;\n const expectedDevAddr = cmd.docker ? dockerAddr : localAddr;\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 = cmd.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: cmd.port,\n dockerImage: cmd.dockerImage,\n useDocker: cmd.docker,\n stdoutLogFunc: logFunc,\n stderrLogFunc: logFunc,\n });\n\n // Keep waiting for user to cancel the process\n await waitForSignal([childProcess]);\n}\n"],"names":["createLogger","openBrowser","runMkdocsServer","waitForSignal"],"mappings":";;;;;;;;;;;;AAsBA,eAAA,WAAA,CAA0C,GAAc,EAAA;AACtD,EAAA,MAAM,SAASA,oBAAa,CAAA,EAAE,OAAS,EAAA,GAAA,CAAI,SAAS,CAAA,CAAA;AAEpD,EAAM,MAAA,UAAA,GAAa,kBAAkB,GAAI,CAAA,IAAA,CAAA,CAAA,CAAA;AACzC,EAAM,MAAA,SAAA,GAAY,oBAAoB,GAAI,CAAA,IAAA,CAAA,CAAA,CAAA;AAC1C,EAAM,MAAA,eAAA,GAAkB,GAAI,CAAA,MAAA,GAAS,UAAa,GAAA,SAAA,CAAA;AAElD,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,GAAI,CAAA,MAAA,GAAS,iBAAoB,GAAA,UAAA,CAAA;AACnD,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,GAAI,CAAA,IAAA;AAAA,IACV,aAAa,GAAI,CAAA,WAAA;AAAA,IACjB,WAAW,GAAI,CAAA,MAAA;AAAA,IACf,aAAe,EAAA,OAAA;AAAA,IACf,aAAe,EAAA,OAAA;AAAA,GAChB,CAAA,CAAA;AAGD,EAAM,MAAAC,0BAAA,CAAc,CAAC,YAAY,CAAC,CAAA,CAAA;AACpC;;;;"}
1
+ {"version":3,"file":"mkdocs-7c045a2a.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 { Command } 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';\n\nexport default async function serveMkdocs(cmd: Command) {\n const logger = createLogger({ verbose: cmd.verbose });\n\n const dockerAddr = `http://0.0.0.0:${cmd.port}`;\n const localAddr = `http://127.0.0.1:${cmd.port}`;\n const expectedDevAddr = cmd.docker ? dockerAddr : localAddr;\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 = cmd.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: cmd.port,\n dockerImage: cmd.dockerImage,\n dockerEntrypoint: cmd.dockerEntrypoint,\n useDocker: cmd.docker,\n stdoutLogFunc: logFunc,\n stderrLogFunc: logFunc,\n });\n\n // Keep waiting for user to cancel the process\n await waitForSignal([childProcess]);\n}\n"],"names":["createLogger","openBrowser","runMkdocsServer","waitForSignal"],"mappings":";;;;;;;;;;;;AAsBA,eAAA,WAAA,CAA0C,GAAc,EAAA;AACtD,EAAA,MAAM,SAASA,oBAAa,CAAA,EAAE,OAAS,EAAA,GAAA,CAAI,SAAS,CAAA,CAAA;AAEpD,EAAM,MAAA,UAAA,GAAa,kBAAkB,GAAI,CAAA,IAAA,CAAA,CAAA,CAAA;AACzC,EAAM,MAAA,SAAA,GAAY,oBAAoB,GAAI,CAAA,IAAA,CAAA,CAAA,CAAA;AAC1C,EAAM,MAAA,eAAA,GAAkB,GAAI,CAAA,MAAA,GAAS,UAA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"-p",
69
69
  `${port}:${port}`,
70
70
  "-it",
71
+ ...options.dockerEntrypoint ? ["--entrypoint", options.dockerEntrypoint] : [],
71
72
  dockerImage,
72
73
  "serve",
73
74
  "--dev-addr",
@@ -85,4 +86,4 @@ const runMkdocsServer = async (options) => {
85
86
 
86
87
  exports.runMkdocsServer = runMkdocsServer;
87
88
  exports.waitForSignal = waitForSignal;
88
- //# sourceMappingURL=mkdocsServer-758a3ae9.cjs.js.map
89
+ //# sourceMappingURL=mkdocsServer-0af6527d.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mkdocsServer-758a3ae9.cjs.js","sources":["../../src/lib/run.ts","../../src/lib/mkdocsServer.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { spawn, SpawnOptions, ChildProcess } from 'child_process';\n\nexport type LogFunc = (data: Buffer | string) => void;\ntype SpawnOptionsPartialEnv = Omit<SpawnOptions, 'env'> & {\n env?: Partial<NodeJS.ProcessEnv>;\n // Pipe stdout to this log function\n stdoutLogFunc?: LogFunc;\n // Pipe stderr to this log function\n stderrLogFunc?: LogFunc;\n};\n\n// TODO: Accept log functions to pipe logs with.\n// Runs a child command, returning the child process instance.\n// Use it along with waitForSignal to run a long running process e.g. mkdocs serve\nexport const run = async (\n name: string,\n args: string[] = [],\n options: SpawnOptionsPartialEnv = {},\n): Promise<ChildProcess> => {\n const { stdoutLogFunc, stderrLogFunc } = options;\n\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n FORCE_COLOR: 'true',\n ...(options.env ?? {}),\n };\n\n // Refer: https://nodejs.org/api/child_process.html#child_process_subprocess_stdio\n const stdio = [\n 'inherit',\n stdoutLogFunc ? 'pipe' : 'inherit',\n stderrLogFunc ? 'pipe' : 'inherit',\n ] as ('inherit' | 'pipe')[];\n\n const childProcess = spawn(name, args, {\n stdio: stdio,\n ...options,\n env,\n });\n\n if (stdoutLogFunc && childProcess.stdout) {\n childProcess.stdout.on('data', stdoutLogFunc);\n }\n if (stderrLogFunc && childProcess.stderr) {\n childProcess.stderr.on('data', stderrLogFunc);\n }\n\n return childProcess;\n};\n\n// Block indefinitely and wait for a signal to kill the child process(es)\n// Throw error if any child process errors\n// Resolves only when all processes exit with status code 0\nexport async function waitForSignal(\n childProcesses: Array<ChildProcess>,\n): Promise<void> {\n const promises: Array<Promise<void>> = [];\n\n for (const signal of ['SIGINT', 'SIGTERM'] as const) {\n process.on(signal, () => {\n childProcesses.forEach(childProcess => {\n childProcess.kill();\n });\n });\n }\n\n childProcesses.forEach(childProcess => {\n if (typeof childProcess.exitCode === 'number') {\n if (childProcess.exitCode) {\n throw new Error(`Non zero exit code from child process`);\n }\n return;\n }\n\n promises.push(\n new Promise<void>((resolve, reject) => {\n childProcess.once('error', reject);\n childProcess.once('exit', resolve);\n }),\n );\n });\n\n await Promise.all(promises);\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 { ChildProcess } from 'child_process';\nimport { run, LogFunc } from './run';\n\nexport const runMkdocsServer = async (options: {\n port?: string;\n useDocker?: boolean;\n dockerImage?: string;\n stdoutLogFunc?: LogFunc;\n stderrLogFunc?: LogFunc;\n}): Promise<ChildProcess> => {\n const port = options.port ?? '8000';\n const useDocker = options.useDocker ?? true;\n const dockerImage = options.dockerImage ?? 'spotify/techdocs';\n\n if (useDocker) {\n return await run(\n 'docker',\n [\n 'run',\n '--rm',\n '-w',\n '/content',\n '-v',\n `${process.cwd()}:/content`,\n '-p',\n `${port}:${port}`,\n '-it',\n dockerImage,\n 'serve',\n '--dev-addr',\n `0.0.0.0:${port}`,\n ],\n {\n stdoutLogFunc: options.stdoutLogFunc,\n stderrLogFunc: options.stderrLogFunc,\n },\n );\n }\n\n return await run('mkdocs', ['serve', '--dev-addr', `127.0.0.1:${port}`], {\n stdoutLogFunc: options.stdoutLogFunc,\n stderrLogFunc: options.stderrLogFunc,\n });\n};\n"],"names":["spawn"],"mappings":";;;;AA6Ba,MAAA,GAAA,GAAM,OACjB,IACA,EAAA,IAAA,GAAiB,EACjB,EAAA,OAAA,GAAkC,EACR,KAAA;AAjC5B,EAAA,IAAA,EAAA,CAAA;AAkCE,EAAM,MAAA,EAAE,eAAe,aAAkB,EAAA,GAAA,OAAA,CAAA;AAEzC,EAAA,MAAM,GAAyB,GAAA;AAAA,IAAA,GAC1B,OAAQ,CAAA,GAAA;AAAA,IACX,WAAa,EAAA,MAAA;AAAA,IACT,GAAA,CAAA,EAAA,GAAA,OAAA,CAAQ,GAAR,KAAA,IAAA,GAAA,EAAA,GAAe,EAAC;AAAA,GACtB,CAAA;AAGA,EAAA,MAAM,KAAQ,GAAA;AAAA,IACZ,SAAA;AAAA,IACA,gBAAgB,MAAS,GAAA,SAAA;AAAA,IACzB,gBAAgB,MAAS,GAAA,SAAA;AAAA,GAC3B,CAAA;AAEA,EAAM,MAAA,YAAA,GAAeA,mBAAM,CAAA,IAAA,EAAM,IAAM,EAAA;AAAA,IACrC,KAAA;AAAA,IACG,GAAA,OAAA;AAAA,IACH,GAAA;AAAA,GACD,CAAA,CAAA;AAED,EAAI,IAAA,aAAA,IAAiB,aAAa,MAAQ,EAAA;AACxC,IAAa,YAAA,CAAA,MAAA,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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 { spawn, SpawnOptions, ChildProcess } from 'child_process';\n\nexport type LogFunc = (data: Buffer | string) => void;\ntype SpawnOptionsPartialEnv = Omit<SpawnOptions, 'env'> & {\n env?: Partial<NodeJS.ProcessEnv>;\n // Pipe stdout to this log function\n stdoutLogFunc?: LogFunc;\n // Pipe stderr to this log function\n stderrLogFunc?: LogFunc;\n};\n\n// TODO: Accept log functions to pipe logs with.\n// Runs a child command, returning the child process instance.\n// Use it along with waitForSignal to run a long running process e.g. mkdocs serve\nexport const run = async (\n name: string,\n args: string[] = [],\n options: SpawnOptionsPartialEnv = {},\n): Promise<ChildProcess> => {\n const { stdoutLogFunc, stderrLogFunc } = options;\n\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n FORCE_COLOR: 'true',\n ...(options.env ?? {}),\n };\n\n // Refer: https://nodejs.org/api/child_process.html#child_process_subprocess_stdio\n const stdio = [\n 'inherit',\n stdoutLogFunc ? 'pipe' : 'inherit',\n stderrLogFunc ? 'pipe' : 'inherit',\n ] as ('inherit' | 'pipe')[];\n\n const childProcess = spawn(name, args, {\n stdio: stdio,\n ...options,\n env,\n });\n\n if (stdoutLogFunc && childProcess.stdout) {\n childProcess.stdout.on('data', stdoutLogFunc);\n }\n if (stderrLogFunc && childProcess.stderr) {\n childProcess.stderr.on('data', stderrLogFunc);\n }\n\n return childProcess;\n};\n\n// Block indefinitely and wait for a signal to kill the child process(es)\n// Throw error if any child process errors\n// Resolves only when all processes exit with status code 0\nexport async function waitForSignal(\n childProcesses: Array<ChildProcess>,\n): Promise<void> {\n const promises: Array<Promise<void>> = [];\n\n for (const signal of ['SIGINT', 'SIGTERM'] as const) {\n process.on(signal, () => {\n childProcesses.forEach(childProcess => {\n childProcess.kill();\n });\n });\n }\n\n childProcesses.forEach(childProcess => {\n if (typeof childProcess.exitCode === 'number') {\n if (childProcess.exitCode) {\n throw new Error(`Non zero exit code from child process`);\n }\n return;\n }\n\n promises.push(\n new Promise<void>((resolve, reject) => {\n childProcess.once('error', reject);\n childProcess.once('exit', resolve);\n }),\n );\n });\n\n await Promise.all(promises);\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 { ChildProcess } from 'child_process';\nimport { run, LogFunc } from './run';\n\nexport const runMkdocsServer = async (options: {\n port?: string;\n useDocker?: boolean;\n dockerImage?: string;\n dockerEntrypoint?: string;\n stdoutLogFunc?: LogFunc;\n stderrLogFunc?: LogFunc;\n}): Promise<ChildProcess> => {\n const port = options.port ?? '8000';\n const useDocker = options.useDocker ?? true;\n const dockerImage = options.dockerImage ?? 'spotify/techdocs';\n\n if (useDocker) {\n return await run(\n 'docker',\n [\n 'run',\n '--rm',\n '-w',\n '/content',\n '-v',\n `${process.cwd()}:/content`,\n '-p',\n `${port}:${port}`,\n '-it',\n ...(options.dockerEntrypoint\n ? ['--entrypoint', options.dockerEntrypoint]\n : []),\n dockerImage,\n 'serve',\n '--dev-addr',\n `0.0.0.0:${port}`,\n ],\n {\n stdoutLogFunc: options.stdoutLogFunc,\n stderrLogFunc: options.stderrLogFunc,\n },\n );\n }\n\n return await run('mkdocs', ['serve', '--dev-addr', `127.0.0.1:${port}`], {\n stdoutLogFunc: options.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AAA;AACb,IAAO,OAAA,MAAM,IACX,QACA,EAAA;AAAA,MACE,KAAA;AAAA,MACA,MAAA;AAAA,MACA,IAAA;AAAA,MACA,UAAA;AAAA,MACA,IAAA;AAAA,MACA,CAAA,EAAG,QAAQ,GAAI,EAAA,CAAA,SAAA,CAAA;AAAA,MACf,IAAA;AAAA,MACA,GAAG,IAAQ,CAAA,CAAA,EAAA,IAAA,CAAA,CAAA;AAAA,MACX,KAAA;AAAA,MACA,GAAI,QAAQ,gBACR,GAAA,CAAC,gBAAgB,OAAQ,CAAA,gBAAgB,IACzC,EAAC;AAAA,MACL,WAAA;AAAA,MACA,OAAA;AAAA,MACA,YAAA;AAAA,MACA,CAAW,QAAA,EAAA,IAAA,CAAA,CAAA;AAAA,KAEb,EAAA;AAAA,MACE,eAAe,OAAQ,CAAA,aAAA;AAAA,MACvB,eAAe,OAAQ,CAAA,aAAA;AAAA,KAE3B,CAAA,CAAA;AAAA,GACF;AAEA,EAAO,OAAA,MAAM,IAAI,QAAU,EAAA,CAAC,SAAS,YAAc,EAAA,CAAA,UAAA,EAAa,MAAM,CAAG,EAAA;AAAA,IACvE,eAAe,OAAQ,CAAA,aAAA;AAAA,IACvB,eAAe,OAAQ,CAAA,aAAA;AAAA,GACxB,CAAA,CAAA;AACH;;;;;"}
@@ -7,7 +7,7 @@ var serveHandler = require('serve-handler');
7
7
  var http = require('http');
8
8
  var httpProxy = require('http-proxy');
9
9
  var utility = require('./utility-51f4a306.cjs.js');
10
- var mkdocsServer = require('./mkdocsServer-758a3ae9.cjs.js');
10
+ var mkdocsServer = require('./mkdocsServer-0af6527d.cjs.js');
11
11
  require('winston');
12
12
  require('child_process');
13
13
 
@@ -112,6 +112,7 @@ async function serve(cmd) {
112
112
  const mkdocsChildProcess = await mkdocsServer.runMkdocsServer({
113
113
  port: cmd.mkdocsPort,
114
114
  dockerImage: cmd.dockerImage,
115
+ dockerEntrypoint: cmd.dockerEntrypoint,
115
116
  useDocker: cmd.docker,
116
117
  stdoutLogFunc: mkdocsLogFunc,
117
118
  stderrLogFunc: mkdocsLogFunc
@@ -141,4 +142,4 @@ Opening browser.`);
141
142
  }
142
143
 
143
144
  exports["default"] = serve;
144
- //# sourceMappingURL=serve-21d1e885.cjs.js.map
145
+ //# sourceMappingURL=serve-66a37894.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"serve-21d1e885.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 mkdocsPort: number;\n private readonly verbose: boolean;\n\n constructor(\n backstageBundleDir: string,\n backstagePort: number,\n mkdocsPort: number,\n verbose: boolean,\n ) {\n this.proxyEndpoint = '/api/';\n this.backstageBundleDir = backstageBundleDir;\n this.backstagePort = backstagePort;\n this.mkdocsPort = mkdocsPort;\n this.verbose = verbose;\n }\n\n // Create a Proxy for mkdocs server\n private createProxy() {\n const proxy = httpProxy.createProxyServer({\n target: `http://localhost:${this.mkdocsPort}`,\n });\n\n return (request: http.IncomingMessage): [httpProxy, string] => {\n // If the request goes to /api/ we want to remove /api/ from the prefix of the request URL.\n // e.g. ['/', 'api', pathChunks]\n const [, , ...pathChunks] = request.url?.split('/') ?? [];\n const forwardPath = pathChunks.join('/');\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 { Command } 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';\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\nexport default async function serve(cmd: Command) {\n const logger = createLogger({ verbose: cmd.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 // TODO: Backstage app port should also be configurable as a CLI option. However, since we bundle\n // a backstage app, we define app.baseUrl in the app-config.yaml.\n // Hence, it is complicated to make this configurable.\n const backstagePort = 3000;\n const backstageBackendPort = 7007;\n\n const mkdocsDockerAddr = `http://0.0.0.0:${cmd.mkdocsPort}`;\n const mkdocsLocalAddr = `http://127.0.0.1:${cmd.mkdocsPort}`;\n const mkdocsExpectedDevAddr = cmd.docker ? mkdocsDockerAddr : mkdocsLocalAddr;\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 = cmd.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: cmd.mkdocsPort,\n dockerImage: cmd.dockerImage,\n useDocker: cmd.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 : backstagePort;\n const httpServer = new HTTPServer(\n findPreviewBundlePath(),\n port,\n cmd.mkdocsPort,\n cmd.verbose,\n );\n\n httpServer\n .serve()\n .catch(err => {\n logger.error(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"],"names":["httpProxy","http","serveHandler","createLogger","path","findPaths","runMkdocsServer","openBrowser","waitForSignal"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,MAAqB,UAAW,CAAA;AAAA,EAO9B,WACE,CAAA,kBAAA,EACA,aACA,EAAA,UAAA,EACA,OACA,EAAA;AACA,IAAA,IAAA,CAAK,aAAgB,GAAA,OAAA,CAAA;AACrB,IAAA,IAAA,CAAK,kBAAqB,GAAA,kBAAA,CAAA;AAC1B,IAAA,IAAA,CAAK,aAAgB,GAAA,aAAA,CAAA;AACrB,IAAA,IAAA,CAAK,UAAa,GAAA,UAAA,CAAA;AAClB,IAAA,IAAA,CAAK,O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AAI,OACN,CAAA,CAAA;AAEA,EACG,UAAA,CAAA,KAAA,EACA,CAAA,KAAA,CAAM,CAAO,GAAA,KAAA;AACZ,IAAA,MAAA,CAAO,MAAM,GAAG,CAAA,CAAA;AAChB,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,IAAA,MAAA,CAAO,KACL,CAAiD,8CAAA,EAAA,IAAA,CAAA;AAAA,gBACnD,CAAA,CAAA,CAAA;AAAA,GACD,CAAA,CAAA;AAEH,EAAM,MAAAC,0BAAA,CAAc,CAAC,kBAAkB,CAAC,CAAA,CAAA;AAC1C;;;;"}
1
+ {"version":3,"file":"serve-66a37894.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 mkdocsPort: number;\n private readonly verbose: boolean;\n\n constructor(\n backstageBundleDir: string,\n backstagePort: number,\n mkdocsPort: number,\n verbose: boolean,\n ) {\n this.proxyEndpoint = '/api/';\n this.backstageBundleDir = backstageBundleDir;\n this.backstagePort = backstagePort;\n this.mkdocsPort = mkdocsPort;\n this.verbose = verbose;\n }\n\n // Create a Proxy for mkdocs server\n private createProxy() {\n const proxy = httpProxy.createProxyServer({\n target: `http://localhost:${this.mkdocsPort}`,\n });\n\n return (request: http.IncomingMessage): [httpProxy, string] => {\n // If the request goes to /api/ we want to remove /api/ from the prefix of the request URL.\n // e.g. ['/', 'api', pathChunks]\n const [, , ...pathChunks] = request.url?.split('/') ?? [];\n const forwardPath = pathChunks.join('/');\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 { Command } 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';\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\nexport default async function serve(cmd: Command) {\n const logger = createLogger({ verbose: cmd.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 // TODO: Backstage app port should also be configurable as a CLI option. However, since we bundle\n // a backstage app, we define app.baseUrl in the app-config.yaml.\n // Hence, it is complicated to make this configurable.\n const backstagePort = 3000;\n const backstageBackendPort = 7007;\n\n const mkdocsDockerAddr = `http://0.0.0.0:${cmd.mkdocsPort}`;\n const mkdocsLocalAddr = `http://127.0.0.1:${cmd.mkdocsPort}`;\n const mkdocsExpectedDevAddr = cmd.docker ? mkdocsDockerAddr : mkdocsLocalAddr;\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 = cmd.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: cmd.mkdocsPort,\n dockerImage: cmd.dockerImage,\n dockerEntrypoint: cmd.dockerEntrypoint,\n useDocker: cmd.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 : backstagePort;\n const httpServer = new HTTPServer(\n findPreviewBundlePath(),\n port,\n cmd.mkdocsPort,\n cmd.verbose,\n );\n\n httpServer\n .serve()\n .catch(err => {\n logger.error(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"],"names":["httpProxy","http","serveHandler","createLogger","path","findPaths","runMkdocsServer","openBr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AC,CAAA,CAAA;AAC1C,IAAA,IAAI,sBAAwB,EAAA;AAC1B,MAAA,MAAA;AAAA,KACF;AACA,IAAA,MAAA,CAAO,KAAK,uCAAuC,CAAA,CAAA;AAAA,GACrD;AAEA,EAAA,IAAI,CAAC,sBAAwB,EAAA;AAC3B,IAAA,MAAA,CAAO,MACL,+FACF,CAAA,CAAA;AAAA,GACF;AAEA,EAAM,MAAA,IAAA,GAAO,YAAY,oBAAuB,GAAA,aAAA,CAAA;AAChD,EAAM,MAAA,UAAA,GAAa,IAAI,UACrB,CAAA,qBAAA,IACA,IACA,EAAA,GAAA,CAAI,UACJ,EAAA,GAAA,CAAI,OACN,CAAA,CAAA;AAEA,EACG,UAAA,CAAA,KAAA,EACA,CAAA,KAAA,CAAM,CAAO,GAAA,KAAA;AACZ,IAAA,MAAA,CAAO,MAAM,GAAG,CAAA,CAAA;AAChB,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,IAAA,MAAA,CAAO,KACL,CAAiD,8CAAA,EAAA,IAAA,CAAA;AAAA,gBACnD,CAAA,CAAA,CAAA;AAAA,GACD,CAAA,CAAA;AAEH,EAAM,MAAAC,0BAAA,CAAc,CAAC,kBAAkB,CAAC,CAAA,CAAA;AAC1C;;;;"}
@@ -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.a23703fe.js"></script><script defer="defer" src="/static/module-material-ui.a1b91103.js"></script><script defer="defer" src="/static/module-lodash.f158b49a.js"></script><script defer="defer" src="/static/module-date-fns.a08d117e.js"></script><script defer="defer" src="/static/module-ajv.d6f6d109.js"></script><script defer="defer" src="/static/module-material-table.cbad0c40.js"></script><script defer="defer" src="/static/module-yaml.574c3290.js"></script><script defer="defer" src="/static/module-hot-loader.7c7a4226.js"></script><script defer="defer" src="/static/module-react-beautiful-dnd.a9014a2e.js"></script><script defer="defer" src="/static/vendor.a23703fe.js"></script><script defer="defer" src="/static/main.a23703fe.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Backstage is an open platform for building developer portals"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json" crossorigin="use-credentials"/><link rel="icon" href="/favicon.ico"/><link rel="shortcut icon" href="/favicon.ico"/><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"/><title>Techdocs Preview App</title><script defer="defer" src="/static/runtime.a260d25c.js"></script><script defer="defer" src="/static/module-material-ui.a1b91103.js"></script><script defer="defer" src="/static/module-lodash.f158b49a.js"></script><script defer="defer" src="/static/module-date-fns.a08d117e.js"></script><script defer="defer" src="/static/module-ajv.d6f6d109.js"></script><script defer="defer" src="/static/module-material-table.cbad0c40.js"></script><script defer="defer" src="/static/module-yaml.574c3290.js"></script><script defer="defer" src="/static/module-hot-loader.7c7a4226.js"></script><script defer="defer" src="/static/module-react-beautiful-dnd.a9014a2e.js"></script><script defer="defer" src="/static/vendor.a260d25c.js"></script><script defer="defer" src="/static/main.a260d25c.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
@@ -486,4 +486,4 @@ Feedback:`),vt=(Te==null?void 0:Te.type)==="github"?(0,C.Pb)(ie.href,"blob"):ie.
486
486
  `})]),[Fe,vt,Ee,Te,De,ie,U,j,qe]),ht=(0,r.useCallback)(async st=>Bt(st,[Zt(),rt(U),oe({baseUrl:window.location.origin,onClick:(Ue,N)=>{var H,k;const y=Ue.ctrlKey||Ue.metaKey,x=new URL(N);x.hash?y?window.open(`${x.pathname}${x.hash}`,"_blank"):(J(`${x.pathname}${x.hash}`),(H=st==null?void 0:st.querySelector(`[id='${x.hash.slice(1)}']`))==null||H.scrollIntoView()):y?window.open(x.pathname,"_blank"):(J(x.pathname),(k=st==null?void 0:st.querySelector(".md-content__inner"))==null||k.scrollIntoView())}}),xe({docStorageUrl:await ie.getApiOrigin(),onLoading:Ue=>{Ue.style.setProperty("opacity","0")},onLoaded:Ue=>{var N;Ue.style.removeProperty("opacity"),(N=Ue.querySelector(".md-nav__title"))==null||N.removeAttribute("for"),ge(Array.from(Ue.querySelectorAll(".md-sidebar")))}})]),[U,J,ie]);return(0,r.useEffect)(()=>{if(!S)return()=>{};let st=!0;return Je(S,B).then(async Ue=>{if(!(Ue!=null&&Ue.innerHTML)||!st)return;window.scroll({top:0});const N=await ht(Ue);Se(N)}),()=>{st=!1}},[S,B,Je,ht]),me},$e=({entityRef:te,onReady:J=()=>{},withSearch:U=!0})=>{var Fe,vt;const ie=X(),Te=Ze(te),De=(0,r.useRef)(null),Ee=(0,r.useRef)(J);return(0,r.useEffect)(()=>{Ee.current=J},[J]),(0,r.useEffect)(()=>{if(!Te||!De.current)return;const xt=De.current,B=xt.shadowRoot||xt.attachShadow({mode:"open"});Array.from(B.children).forEach(S=>B.removeChild(S)),B.appendChild(Te),Ee.current()},[Te]),r.createElement(r.Fragment,null,r.createElement(ze.N,null),U&&((vt=(Fe=De==null?void 0:De.current)==null?void 0:Fe.shadowRoot)==null?void 0:vt.innerHTML)&&r.createElement(i.Z,{container:!0,className:ie.searchBar},r.createElement(Lt.S,{entityId:te})),r.createElement("div",{"data-testid":"techdocs-content-shadowroot",ref:De}))},nt=te=>{const{entityRef:J,onReady:U=()=>{},withSearch:ie=!0}=te;return r.createElement(ne,{entityRef:J},r.createElement($e,{entityRef:J,onReady:U,withSearch:ie}))}},75733:function(_,s,e){"use strict";e.r(s),e.d(s,{TechDocsReaderPage:function(){return u}});var r=e(2784),t=e(10289),l=e(64279),f=e(53242),E=e(75505),i=e(3337),o=e(36964),m=e(9118);const u=h=>{const{children:g}=h,{NotFoundErrorPage:R}=(0,o.useApp)().getComponents(),C=(0,t.pC)(),[M,b]=(0,r.useState)(!1),{namespace:Q,kind:I,name:P}=(0,t.UO)(),L=(0,o.useApi)(i.g),{value:z}=(0,l.default)(()=>M?L.getTechDocsMetadata({kind:I,namespace:Q,name:P}):Promise.resolve(void 0),[I,Q,P,L,M]),{value:W,error:q}=(0,l.default)(()=>L.getEntityMetadata({kind:I,namespace:Q,name:P}),[I,Q,P,L]),oe=(0,r.useCallback)(()=>{b(!0)},[b]);return q?r.createElement(R,null):g?r.createElement(m.Page,{themeId:"documentation"},g instanceof Function?g({techdocsMetadataValue:z,entityMetadataValue:W,entityRef:{kind:I,namespace:Q,name:P},onReady:oe}):g):C||r.createElement(m.Page,{themeId:"documentation"},r.createElement(E.S,{techDocsMetadata:z,entityMetadata:W,entityRef:{kind:I,namespace:Q,name:P}}),r.createElement(m.Content,{"data-testid":"techdocs-content"},r.createElement(f.Ej,{onReady:oe,entityRef:{kind:I,namespace:Q,name:P}})))}},75505:function(_,s,e){"use strict";e.d(s,{S:function(){return m}});var r=e(2784),t=e(73250),l=e(36964),f=e(9118),E=e(48023),i=e(53479),o=e(68725);const m=u=>{const{entityRef:h,entityMetadata:g,techDocsMetadata:R,children:C}=u,{name:M}=h,{site_name:b,site_description:Q}=R||{},{locationMetadata:I,spec:P}=g||{},L=P==null?void 0:P.lifecycle,z=g?(0,i.getEntityRelations)(g,E.S4):[],W=(0,l.useRouteRef)(o._Z)(),q=r.createElement(r.Fragment,null,r.createElement(f.HeaderLabel,{label:"Component",value:r.createElement(i.EntityRefLink,{color:"inherit",entityRef:h,defaultKind:"Component"})}),z.length>0&&r.createElement(f.HeaderLabel,{label:"Owner",value:r.createElement(i.EntityRefLinks,{color:"inherit",entityRefs:z,defaultKind:"group"})}),L?r.createElement(f.HeaderLabel,{label:"Lifecycle",value:L}):null,I&&I.type!=="dir"&&I.type!=="file"?r.createElement(f.HeaderLabel,{label:"",value:r.createElement("a",{href:I.target,target:"_blank",rel:"noopener noreferrer"},r.createElement(t.Z,{style:{marginTop:"-25px",fill:"#fff"}}))}):null);return r.createElement(f.Header,{title:b||".",pageTitleOverride:b||M,subtitle:Q&&Q!=="None"?Q:"",type:"Docs",typeLink:W},q,C)}},23738:function(_,s,e){"use strict";e.d(s,{N:function(){return z}});var r=e(2784),t=e(9118),l=e(79692),f=e(4614),E=e(77277),i=e(99688),o=e(12420),m=e(60905),u=e(90436),h=e(61837),g=e(4190),R=e(87685);const C=(0,l.Z)(W=>(0,o.Z)({paper:{width:"100%",[W.breakpoints.up("sm")]:{width:"75%"},[W.breakpoints.up("md")]:{width:"50%"},padding:W.spacing(2.5)},root:{height:"100%",overflow:"hidden"},logs:{background:W.palette.background.default}})),M=({buildLog:W,onClose:q})=>{const oe=C(),ve=W.length===0?"Waiting for logs...":W.join(`
487
487
  `);return r.createElement(m.Z,{container:!0,direction:"column",className:oe.root,spacing:0,wrap:"nowrap"},r.createElement(m.Z,{item:!0,container:!0,justifyContent:"space-between",alignItems:"center",spacing:0,wrap:"nowrap"},r.createElement(u.Z,{variant:"h5"},"Build Details"),r.createElement(h.Z,{key:"dismiss",title:"Close the drawer",onClick:q,color:"inherit"},r.createElement(R.Z,null))),r.createElement(t.LogViewer,{text:ve,classes:{root:oe.logs}}))},b=({buildLog:W})=>{const q=C(),[oe,ve]=(0,r.useState)(!1);return r.createElement(r.Fragment,null,r.createElement(E.Z,{color:"inherit",onClick:()=>ve(!0)},"Show Build Logs"),r.createElement(g.ZP,{classes:{paper:q.paper},anchor:"right",open:oe,onClose:()=>ve(!1)},r.createElement(M,{buildLog:W,onClose:()=>ve(!1)})))};var Q=e(36964);const I=({errorMessage:W})=>{const q=(0,Q.useApi)(Q.configApiRef).getOptionalString("techdocs.builder");let oe="";return q!=="local"&&(oe="Note that techdocs.builder is not set to 'local' in your config, which means this Backstage app will not generate docs if they are not found. Make sure the project's docs are generated and published by some external process (e.g. CI/CD pipeline). Or change techdocs.builder to 'local' to generate docs from this Backstage instance."),r.createElement(t.ErrorPage,{status:"404",statusMessage:W||"Documentation not found",additionalInfo:oe})};var P=e(53242);const L=(0,l.Z)(W=>({root:{marginBottom:W.spacing(2)},message:{wordBreak:"break-word",overflowWrap:"anywhere"}})),z=()=>{let W=null;const q=L(),{state:oe,contentReload:ve,contentErrorMessage:Le,syncErrorMessage:we,buildLog:fe}=(0,P.DK)(),Ke=oe==="CHECKING"?r.createElement(t.Progress,null):null;return oe==="INITIAL_BUILD"&&(W=r.createElement(i.Z,{classes:{root:q.root},variant:"outlined",severity:"info",icon:r.createElement(f.Z,{size:"24px"}),action:r.createElement(b,{buildLog:fe})},"Documentation is accessed for the first time and is being prepared. The subsequent loads are much faster.")),oe==="CONTENT_STALE_REFRESHING"&&(W=r.createElement(i.Z,{variant:"outlined",severity:"info",icon:r.createElement(f.Z,{size:"24px"}),action:r.createElement(b,{buildLog:fe}),classes:{root:q.root}},"A newer version of this documentation is being prepared and will be available shortly.")),oe==="CONTENT_STALE_READY"&&(W=r.createElement(i.Z,{variant:"outlined",severity:"success",action:r.createElement(E.Z,{color:"inherit",onClick:()=>ve()},"Refresh"),classes:{root:q.root}},"A newer version of this documentation is now available, please refresh to view.")),oe==="CONTENT_STALE_ERROR"&&(W=r.createElement(i.Z,{variant:"outlined",severity:"error",action:r.createElement(b,{buildLog:fe}),classes:{root:q.root,message:q.message}},"Building a newer version of this documentation failed."," ",we)),oe==="CONTENT_NOT_FOUND"&&(W=r.createElement(r.Fragment,null,we&&r.createElement(i.Z,{variant:"outlined",severity:"error",action:r.createElement(b,{buildLog:fe}),classes:{root:q.root,message:q.message}},"Building a newer version of this documentation failed."," ",we),r.createElement(I,{errorMessage:Le}))),r.createElement(r.Fragment,null,Ke,W)}},96393:function(_,s,e){"use strict";e.d(s,{Ej:function(){return r.Ej},SE:function(){return t.S}});var r=e(53242),t=e(75505),l=e(23738)},68725:function(_,s,e){"use strict";e.d(s,{Fw:function(){return l},_Z:function(){return t},pd:function(){return f}});var r=e(36964);const t=(0,r.createRouteRef)({id:"techdocs:index-page"}),l=(0,r.createRouteRef)({id:"techdocs:reader-page",params:["namespace","kind","name"]}),f=(0,r.createRouteRef)({id:"techdocs:catalog-reader-view"})},93566:function(_,s,e){"use strict";e.d(s,{S:function(){return xt}});var r=e(2784),t=e(79692),l=e(49378),f=e(38402),E=e(85256),i=e(9118),o=e(15277),m=e.n(o);const u=(0,t.Z)({flexContainer:{flexWrap:"wrap"},itemText:{width:"100%",marginBottom:"1rem"}}),h=B=>{const{result:S,lineClamp:j=5,asListItem:ue=!0,asLink:ge=!0,title:me}=B,Se=u(),qe=()=>{var Je;return r.createElement(l.Z,{className:Se.itemText,primaryTypographyProps:{variant:"h6"},primary:me||`${S.title} | ${(Je=S.entityTitle)!=null?Je:S.name} docs`,secondary:r.createElement(m(),{line:j,truncateText:"\u2026",text:S.text,element:"span"})})},ot=({children:Je})=>ge?r.createElement(i.Link,{to:S.location},Je):r.createElement(r.Fragment,null,Je),Ve=({children:Je})=>ue?r.createElement(r.Fragment,null,r.createElement(f.Z,{alignItems:"flex-start",className:Se.flexContainer},Je),r.createElement(E.Z,{component:"li"})):r.createElement(r.Fragment,null,Je);return r.createElement(ot,null,r.createElement(Ve,null,r.createElement(qe,null)))};var g=e(91512);const R=(0,t.Z)(B=>({filters:{width:"250px",display:"flex"},icon:{margin:B.spacing(-1,0,0,0)}})),C=({numberOfSelectedFilters:B,handleToggleFilters:S})=>{const j=R();return React.createElement("div",{className:j.filters},React.createElement(IconButton,{className:j.icon,"aria-label":"settings",onClick:S},React.createElement(FilterListIcon,null)),React.createElement(Typography,{variant:"h6"},"Filters (",B||0,")"))},M=(0,t.Z)(B=>({filters:{background:"transparent",boxShadow:"0px 0px 0px 0px"},checkbox:{padding:B.spacing(0,1,0,1)},dropdown:{width:"100%"}})),b=({filters:B,filterOptions:S,resetFilters:j,updateSelected:ue,updateChecked:ge})=>{const me=M();return React.createElement(Card,{className:me.filters},React.createElement(CardHeader,{title:React.createElement(Typography,{variant:"h6"},"Filters"),action:React.createElement(Button,{color:"primary",onClick:()=>j()},"CLEAR ALL")}),React.createElement(Divider,null),S.kind.length===0&&S.lifecycle.length===0&&React.createElement(CardContent,null,React.createElement(Typography,{variant:"subtitle2"},"Filters cannot be applied to available results")),S.kind.length>0&&React.createElement(CardContent,null,React.createElement(Typography,{variant:"subtitle2"},"Kind"),React.createElement(Select,{id:"outlined-select",onChange:Se=>{var qe;return ue((qe=Se==null?void 0:Se.target)==null?void 0:qe.value)},variant:"outlined",className:me.dropdown,value:B.selected},S.kind.map(Se=>React.createElement(MenuItem,{selected:Se==="",dense:!0,key:Se,value:Se},Se)))),S.lifecycle.length>0&&React.createElement(CardContent,null,React.createElement(Typography,{variant:"subtitle2"},"Lifecycle"),React.createElement(List,{disablePadding:!0,dense:!0},S.lifecycle.map(Se=>React.createElement(ListItem,{key:Se,dense:!0,button:!0,onClick:()=>ge(Se)},React.createElement(Checkbox,{edge:"start",disableRipple:!0,className:me.checkbox,color:"primary",checked:B.checked.includes(Se),tabIndex:-1,value:Se,name:Se}),React.createElement(ListItemText,{id:Se,primary:Se}))))))};var Q=e(1795),I=e(22313),P=e(42494),L=e(84899),z=e(5806),W=e(21324),q=e(56939),oe=e(73698),ve=e(12231),Le=e(86619),we=e(7089),fe=e(88013),Ke=e(69294),_e=e(48760);const ut=(B,S,j=[],ue=250)=>{const ge=(0,r.useRef)({}),me=B||(()=>Promise.resolve([])),[Se,qe]=(0,Ke.default)(me,[S],{loading:!0});if((0,_e.Z)(()=>{ge.current[S]===void 0&&(ge.current[S]=qe(S).then(Ve=>(ge.current[S]=Ve,Ve)))},ue,[qe,S]),j.length)return{loading:!1,value:j};const ot=ge.current[S];return Array.isArray(ot)?{loading:!1,value:ot}:Se},rt=(B,S)=>{const{setFilters:j}=(0,I.Rx)();(0,r.useEffect)(()=>{S&&[S].flat().length>0&&j(ue=>({...ue,[B]:S}))},[])},at=B=>{const{className:S,defaultValue:j,name:ue,values:ge,valuesDebounceMs:me,label:Se,filterSelectedOptions:qe,limitTags:ot,multiple:Ve}=B,[Je,ht]=(0,r.useState)("");rt(ue,j);const st=typeof ge=="function"?ge:void 0,Ue=typeof ge=="function"?void 0:ge,{value:N,loading:y}=ut(st,Je,Ue,me),{filters:x,setFilters:H}=(0,I.Rx)(),k=x[ue]||(Ve?[]:null),Oe=(He,ft)=>{H(Ht=>{const{[ue]:qt,...Mn}=Ht;return ft?{...Mn,[ue]:ft}:{...Mn}})},Ae=He=>r.createElement(Le.Z,{...He,name:"search",variant:"outlined",label:Se,fullWidth:!0}),Ie=(He,ft)=>He.map((Ht,qt)=>r.createElement(we.Z,{label:Ht,color:"primary",...ft({index:qt})}));return r.createElement(fe.ZP,{filterSelectedOptions:qe,limitTags:ot,multiple:Ve,className:S,id:`${Ve?"multi-":""}select-filter-${ue}--select`,options:N||[],loading:y,value:k,onChange:Oe,onInputChange:(He,ft)=>ht(ft),renderInput:Ae,renderTags:Ie})},gt=(0,t.Z)({label:{textTransform:"capitalize"}}),xe=B=>{const{className:S,defaultValue:j,label:ue,name:ge,values:me=[],valuesDebounceMs:Se}=B,qe=gt(),{filters:ot,setFilters:Ve}=(0,I.Rx)();rt(ge,j);const Je=typeof me=="function"?me:void 0,ht=typeof me=="function"?void 0:me,{value:st=[],loading:Ue}=ut(Je,"",ht,Se),N=y=>{const{target:{value:x,checked:H}}=y;Ve(k=>{const{[ge]:Oe,...Ae}=k,Ie=(Oe||[]).filter(ft=>ft!==x),He=H?[...Ie,x]:Ie;return He.length?{...Ae,[ge]:He}:Ae})};return r.createElement(P.Z,{className:S,disabled:Ue,fullWidth:!0,"data-testid":"search-checkboxfilter-next"},ue?r.createElement(L.Z,{className:qe.label},ue):null,st.map(y=>{var x;return r.createElement(z.Z,{key:y,control:r.createElement(W.Z,{color:"primary",tabIndex:-1,inputProps:{"aria-labelledby":y},value:y,name:y,onChange:N,checked:((x=ot[ge])!=null?x:[]).includes(y)}),label:y})}))},Qe=B=>{const{className:S,defaultValue:j,label:ue,name:ge,values:me,valuesDebounceMs:Se}=B,qe=gt();rt(ge,j);const ot=typeof me=="function"?me:void 0,Ve=typeof me=="function"?void 0:me,{value:Je=[],loading:ht}=ut(ot,"",Ve,Se),{filters:st,setFilters:Ue}=(0,I.Rx)(),N=y=>{const{target:{value:x}}=y;Ue(H=>{const{[ge]:k,...Oe}=H;return x?{...Oe,[ge]:x}:Oe})};return r.createElement(P.Z,{disabled:ht,className:S,variant:"filled",fullWidth:!0,"data-testid":"search-selectfilter-next"},ue?r.createElement(q.Z,{className:qe.label,margin:"dense"},ue):null,r.createElement(oe.Z,{variant:"outlined",value:st[ge]||"",onChange:N},r.createElement(ve.Z,{value:""},r.createElement("em",null,"All")),Je.map(y=>r.createElement(ve.Z,{key:y,value:y},y))))},Ye=({component:B,...S})=>r.createElement(B,{...S});Ye.Checkbox=B=>r.createElement(Ye,{...B,component:xe}),Ye.Select=B=>r.createElement(Ye,{...B,component:Qe}),Ye.Autocomplete=B=>r.createElement(Ye,{...B,component:at});const Rt=null;var pt=e(73032),St=e(3992),it=e(8542),yt=e(62155),It=e(94339),Pt=e(32552),Zt=e(24579),Bt=e(27616),Lt=e(8284),ze=e(70660),lt=e(11776),ke=e(86136),Ct=e(38016),ct=e(56881);const Et=(0,t.Z)(B=>({card:{backgroundColor:"rgba(0, 0, 0, .11)"},cardContent:{paddingTop:B.spacing(1)},icon:{color:B.palette.common.black},list:{width:"100%"},listItemIcon:{width:"24px",height:"24px"},accordion:{backgroundColor:B.palette.background.paper},accordionSummary:{minHeight:"auto","&.Mui-expanded":{minHeight:"auto"}},accordionSummaryContent:{margin:B.spacing(2,0),"&.Mui-expanded":{margin:B.spacing(2,0)}},accordionDetails:{padding:B.spacing(0,0,1)}})),X=B=>{const S=Et(),{setPageCursor:j,setTypes:ue,types:ge}=(0,I.Rx)(),[me,Se]=(0,r.useState)(!0),{defaultValue:qe,name:ot,types:Ve}=B,Je=()=>Se(N=>!N),ht=N=>()=>{ue(N!==""?[N]:[]),j(void 0),Se(!1)};(0,r.useEffect)(()=>{qe&&ue([qe])},[]);const st=[{value:"",name:"All",icon:r.createElement(ct.Z,null)},...Ve],Ue=ge[0]||"";return r.createElement(It.Z,{className:S.card},r.createElement(Pt.Z,{title:ot,titleTypographyProps:{variant:"overline"}}),r.createElement(Zt.Z,{className:S.cardContent},r.createElement(Bt.Z,{className:S.accordion,expanded:me,onChange:Je},r.createElement(Lt.Z,{classes:{root:S.accordionSummary,content:S.accordionSummaryContent},expandIcon:r.createElement(Ct.Z,{className:S.icon}),IconButtonProps:{size:"small"}},me?"Collapse":st.filter(N=>N.value===Ue)[0].name),r.createElement(ze.Z,{classes:{root:S.accordionDetails}},r.createElement(lt.Z,{className:S.list,component:"nav","aria-label":"filter by type",disablePadding:!0,dense:!0},st.map(N=>r.createElement(r.Fragment,{key:N.value},r.createElement(E.Z,null),r.createElement(f.Z,{selected:ge[0]===N.value||ge.length===0&&N.value==="",onClick:ht(N.value),button:!0},r.createElement(ke.Z,null,(0,r.cloneElement)(N.icon,{className:S.listItemIcon})),r.createElement(l.Z,{primary:N.name})))))))))};var Z=e(99152),ne=e(6487);const ce=(0,t.Z)(B=>({tabs:{borderBottom:`1px solid ${B.palette.textVerySubtle}`,padding:B.spacing(0,4)},tab:{height:"50px",fontWeight:B.typography.fontWeightBold,fontSize:B.typography.pxToRem(13),color:B.palette.textSubtle,minWidth:"130px"}})),se=B=>{const S=ce(),{setPageCursor:j,setTypes:ue,types:ge}=(0,I.Rx)(),{defaultValue:me,types:Se}=B,qe=(Ve,Je)=>{ue(Je!==""?[Je]:[]),j(void 0)};(0,r.useEffect)(()=>{me&&ue([me])},[]);const ot=[{value:"",name:"All"},...Se];return r.createElement(Z.Z,{className:S.tabs,indicatorColor:"primary",value:ge.length===0?"":ge[0],onChange:qe},ot.map(Ve=>r.createElement(ne.Z,{className:S.tab,disableRipple:!0,label:Ve.name,value:Ve.value})))},ye=(0,t.Z)(B=>({label:{textTransform:"capitalize"},chips:{display:"flex",flexWrap:"wrap",marginTop:B.spacing(1)},chip:{margin:2}})),Ze=B=>{const{className:S,defaultValue:j,name:ue,values:ge=[]}=B,me=ye(),{types:Se,setTypes:qe}=(0,I.Rx)();(0,yt.Z)(()=>{Se.length||(j&&Array.isArray(j)?qe(j):j&&qe([j]))});const ot=Ve=>{const Je=Ve.target.value;qe(Je)};return r.createElement(P.Z,{className:S,variant:"filled",fullWidth:!0,"data-testid":"search-typefilter-next"},r.createElement(q.Z,{className:me.label,margin:"dense"},ue),r.createElement(oe.Z,{multiple:!0,variant:"outlined",value:Se,onChange:ot,placeholder:"All Results",renderValue:Ve=>r.createElement("div",{className:me.chips},Ve.map(Je=>r.createElement(we.Z,{key:Je,label:Je,className:me.chip,size:"small"})))},ge.map(Ve=>r.createElement(ve.Z,{key:Ve,value:Ve},r.createElement(W.Z,{checked:Se.indexOf(Ve)>-1}),r.createElement(l.Z,{primary:Ve})))))};Ze.Accordion=B=>r.createElement(X,{...B}),Ze.Tabs=B=>r.createElement(se,{...B});var $e=e(19126),nt=e(20863),te=e(36964);const J=B=>{const S=useRouteRef(rootRouteRef),{focusContent:j}=useContent(),ue=useNavigate(),ge=useCallback(me=>{const Se=qs.stringify({query:me},{addQueryPrefix:!0});j(),ue(`${S()}${Se}`)},[j,ue,S]);return React.createElement(SidebarSearchField,{icon:B.icon,onSearch:ge,to:"/search"})};var U=e(50581),ie=e(61837),Te=e(4614),De=e(21853),Ee=e(10289);const Fe=(0,t.Z)({root:{width:"100%"}}),vt=B=>{const{entityId:S,debounceTime:j=150}=B,[ue,ge]=(0,r.useState)(!1),me=(0,Ee.s0)(),{term:Se,setTerm:qe,setFilters:ot,result:{loading:Ve,value:Je}}=(0,I.Rx)(),ht=Fe(),[st,Ue]=(0,r.useState)([]);(0,r.useEffect)(()=>{let Ie=!0;if(Ie&&Je){const He=Je.results.slice(0,10);Ue(He)}return()=>{Ie=!1}},[Ve,Je]);const[N,y]=(0,r.useState)(Se);(0,_e.Z)(()=>qe(N),j,[N]);const{kind:x,name:H,namespace:k}=S;(0,r.useEffect)(()=>{ot(Ie=>({...Ie,kind:x,namespace:k,name:H}))},[x,k,H,ot]);const Oe=Ie=>{ue||ge(!0),y(Ie.target.value)},Ae=(Ie,He)=>{if(He!=null&&He.document){const{location:ft}=He.document;me(ft)}};return r.createElement(fe.ZP,{classes:{root:ht.root},"data-testid":"techdocs-search-bar",size:"small",open:ue,getOptionLabel:()=>"",filterOptions:Ie=>Ie,onClose:()=>{ge(!1)},onFocus:()=>{ge(!0)},onChange:Ae,blurOnSelect:!0,noOptionsText:"No results found",value:null,options:st,renderOption:({document:Ie})=>r.createElement(h,{result:Ie,lineClamp:3,asListItem:!1,asLink:!1,title:Ie.title}),loading:Ve,renderInput:Ie=>r.createElement(Le.Z,{...Ie,"data-testid":"techdocs-search-bar-input",variant:"outlined",fullWidth:!0,placeholder:`Search ${S.name} docs`,value:N,onChange:Oe,InputProps:{...Ie.InputProps,startAdornment:r.createElement(U.Z,{position:"start"},r.createElement(ie.Z,{"aria-label":"Query",disabled:!0},r.createElement(De.Z,null))),endAdornment:r.createElement(r.Fragment,null,Ve?r.createElement(Te.Z,{color:"inherit",size:20}):null,Ie.InputProps.endAdornment)}})})},xt=B=>{const S={term:"",types:["techdocs"],pageCursor:"",filters:B.entityId};return r.createElement(I.Nd,{initialState:S},r.createElement(vt,{...B}))}},98157:function(){},19133:function(_,s,e){"use strict";_.exports=e.p+"static/createComponent.975d1e1e..svg"},86284:function(_,s,e){"use strict";_.exports=e.p+"static/missingAnnotation.67f79e98..svg"},3871:function(_,s,e){"use strict";_.exports=e.p+"static/noBuild.1715fa71..svg"},96465:function(_,s,e){"use strict";_.exports=e.p+"static/noInformation.4b426325..svg"},29788:function(_,s,e){"use strict";_.exports=e.p+"static/mic-drop.fe3ef4d0..svg"},53260:function(){}},function(_){var s=function(r){return _(_.s=r)};_.O(0,[2370,6202,9284,2126,7012,9035,4983,5218,4736],function(){return s(88649),s(46054)});var e=_.O()}]);})();
488
488
 
489
- //# sourceMappingURL=main.a23703fe.js.map
489
+ //# sourceMappingURL=main.a260d25c.js.map