@backstage/plugin-catalog-import 0.13.17 → 0.13.18-next.1

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,12 +1,28 @@
1
1
  # @backstage/plugin-catalog-import
2
2
 
3
- ## 0.13.17
3
+ ## 0.13.18-next.1
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - f400f2b: Fixed the owner selected in the import stepper being written to the generated `catalog-info.yaml` as a display name instead of an entity reference. Groups are still suggested by their display name, but selecting one now sets a valid `spec.owner`, for example picking `My Team` results in `my-team`.
7
+ - d421187: Reduced the initial app bundle size by loading page and optional UI implementations only when their extensions render.
8
8
  - Updated dependencies
9
- - @backstage/plugin-catalog-react@3.2.2
9
+ - @backstage/core-components@0.18.14-next.1
10
+ - @backstage/integration@2.1.2-next.0
11
+ - @backstage/frontend-plugin-api@0.18.1-next.0
12
+ - @backstage/plugin-catalog-react@3.2.3-next.1
13
+ - @backstage/integration-react@1.2.22-next.0
14
+ - @backstage/core-plugin-api@1.12.10-next.0
15
+ - @backstage/catalog-client@1.16.2-next.0
16
+ - @backstage/plugin-permission-react@0.5.5-next.0
17
+
18
+ ## 0.13.17-next.0
19
+
20
+ ### Patch Changes
21
+
22
+ - 5d6a62b: Fixed the owner selected in the import stepper being written to the generated `catalog-info.yaml` as a display name instead of an entity reference. Groups are still suggested by their display name, but selecting one now sets a valid `spec.owner`, for example picking `My Team` results in `my-team`.
23
+ - Updated dependencies
24
+ - @backstage/plugin-catalog-react@3.2.2-next.0
25
+ - @backstage/core-components@0.18.14-next.0
10
26
 
11
27
  ## 0.13.16
12
28
 
package/dist/alpha.esm.js CHANGED
@@ -7,7 +7,6 @@ import { catalogImportApiRef } from './api/CatalogImportApi.esm.js';
7
7
  import { CatalogImportClient } from './api/CatalogImportClient.esm.js';
8
8
  import { rootRouteRef } from './plugin.esm.js';
9
9
  import { catalogApiRef } from '@backstage/plugin-catalog-react';
10
- import { RequirePermission } from '@backstage/plugin-permission-react';
11
10
  import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha';
12
11
  import { catalogImportTranslationRef as catalogImportTranslationRef$1 } from './translation.esm.js';
13
12
 
@@ -16,7 +15,13 @@ const catalogImportPage = PageBlueprint.make({
16
15
  params: {
17
16
  path: "/catalog-import",
18
17
  routeRef: rootRouteRef,
19
- loader: () => import('./components/ImportPage/index.esm.js').then((m) => /* @__PURE__ */ jsx(RequirePermission, { permission: catalogEntityCreatePermission, children: /* @__PURE__ */ jsx(m.ImportPage, {}) }))
18
+ loader: async () => {
19
+ const [m, { RequirePermission }] = await Promise.all([
20
+ import('./components/ImportPage/index.esm.js'),
21
+ import('@backstage/plugin-permission-react')
22
+ ]);
23
+ return /* @__PURE__ */ jsx(RequirePermission, { permission: catalogEntityCreatePermission, children: /* @__PURE__ */ jsx(m.ImportPage, {}) });
24
+ }
20
25
  }
21
26
  });
22
27
  const catalogImportApi = ApiBlueprint.make({
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RiAddCircleLine } from '@remixicon/react';\n\nimport {\n configApiRef,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/core-plugin-api';\nimport {\n createFrontendPlugin,\n PageBlueprint,\n ApiBlueprint,\n} from '@backstage/frontend-plugin-api';\nimport {\n scmAuthApiRef,\n scmIntegrationsApiRef,\n} from '@backstage/integration-react';\nimport { CatalogImportClient, catalogImportApiRef } from './api';\nimport { rootRouteRef } from './plugin';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport { RequirePermission } from '@backstage/plugin-permission-react';\nimport { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha';\n\nimport { catalogImportTranslationRef as _catalogImportTranslationRef } from './translation';\n\n/**\n * @alpha\n * @deprecated Import from `@backstage/plugin-catalog-import` instead.\n */\nexport const catalogImportTranslationRef = _catalogImportTranslationRef;\n\n// TODO: It's currently possible to override the import page with a custom one. We need to decide\n// whether this type of override is typically done with an input or by overriding the entire extension.\nconst catalogImportPage = PageBlueprint.make({\n params: {\n path: '/catalog-import',\n routeRef: rootRouteRef,\n loader: () =>\n import('./components/ImportPage').then(m => (\n <RequirePermission permission={catalogEntityCreatePermission}>\n <m.ImportPage />\n </RequirePermission>\n )),\n },\n});\n\nconst catalogImportApi = ApiBlueprint.make({\n params: defineParams =>\n defineParams({\n api: catalogImportApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n scmAuthApi: scmAuthApiRef,\n fetchApi: fetchApiRef,\n scmIntegrationsApi: scmIntegrationsApiRef,\n catalogApi: catalogApiRef,\n configApi: configApiRef,\n },\n factory: ({\n discoveryApi,\n scmAuthApi,\n fetchApi,\n scmIntegrationsApi,\n catalogApi,\n configApi,\n }) =>\n new CatalogImportClient({\n discoveryApi,\n scmAuthApi,\n scmIntegrationsApi,\n fetchApi,\n catalogApi,\n configApi,\n }),\n }),\n});\n\n/** @alpha */\nexport default createFrontendPlugin({\n pluginId: 'catalog-import',\n title: 'Register Existing Component',\n icon: <RiAddCircleLine />,\n info: { packageJson: () => import('../package.json') },\n extensions: [catalogImportApi, catalogImportPage],\n routes: {\n importPage: rootRouteRef,\n },\n});\n"],"names":["_catalogImportTranslationRef"],"mappings":";;;;;;;;;;;;;AA4CO,MAAM,2BAAA,GAA8BA;AAI3C,MAAM,iBAAA,GAAoB,cAAc,IAAA,CAAK;AAAA,EAC3C,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,iB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alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RiAddCircleLine } from '@remixicon/react';\n\nimport {\n configApiRef,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/core-plugin-api';\nimport {\n createFrontendPlugin,\n PageBlueprint,\n ApiBlueprint,\n} from '@backstage/frontend-plugin-api';\nimport {\n scmAuthApiRef,\n scmIntegrationsApiRef,\n} from '@backstage/integration-react';\nimport { CatalogImportClient, catalogImportApiRef } from './api';\nimport { rootRouteRef } from './plugin';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha';\n\nimport { catalogImportTranslationRef as _catalogImportTranslationRef } from './translation';\n\n/**\n * @alpha\n * @deprecated Import from `@backstage/plugin-catalog-import` instead.\n */\nexport const catalogImportTranslationRef = _catalogImportTranslationRef;\n\n// TODO: It's currently possible to override the import page with a custom one. We need to decide\n// whether this type of override is typically done with an input or by overriding the entire extension.\nconst catalogImportPage = PageBlueprint.make({\n params: {\n path: '/catalog-import',\n routeRef: rootRouteRef,\n loader: async () => {\n const [m, { RequirePermission }] = await Promise.all([\n import('./components/ImportPage'),\n import('@backstage/plugin-permission-react'),\n ]);\n return (\n <RequirePermission permission={catalogEntityCreatePermission}>\n <m.ImportPage />\n </RequirePermission>\n );\n },\n },\n});\n\nconst catalogImportApi = ApiBlueprint.make({\n params: defineParams =>\n defineParams({\n api: catalogImportApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n scmAuthApi: scmAuthApiRef,\n fetchApi: fetchApiRef,\n scmIntegrationsApi: scmIntegrationsApiRef,\n catalogApi: catalogApiRef,\n configApi: configApiRef,\n },\n factory: ({\n discoveryApi,\n scmAuthApi,\n fetchApi,\n scmIntegrationsApi,\n catalogApi,\n configApi,\n }) =>\n new CatalogImportClient({\n discoveryApi,\n scmAuthApi,\n scmIntegrationsApi,\n fetchApi,\n catalogApi,\n configApi,\n }),\n }),\n});\n\n/** @alpha */\nexport default createFrontendPlugin({\n pluginId: 'catalog-import',\n title: 'Register Existing Component',\n icon: <RiAddCircleLine />,\n info: { packageJson: () => import('../package.json') },\n extensions: [catalogImportApi, catalogImportPage],\n routes: {\n importPage: rootRouteRef,\n },\n});\n"],"names":["_catalogImportTranslationRef"],"mappings":";;;;;;;;;;;;AA2CO,MAAM,2BAAA,GAA8BA;AAI3C,MAAM,iBAAA,GAAoB,cAAc,IAAA,CAAK;AAAA,EAC3C,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,iBAAA;AAAA,IACN,QAAA,EAAU,YAAA;AAAA,IACV,QAAQ,YAAY;AAClB,MAAA,MAAM,CAAC,GAAG,EAAE,iBAAA,EAAmB,CAAA,GAAI,MAAM,QAAQ,GAAA,CAAI;AAAA,QACnD,OAAO,sCAAyB,CAAA;AAAA,QAChC,OAAO,oCAAoC;AAAA,OAC5C,CAAA;AACD,MAAA,uBACE,GAAA,CAAC,qBAAkB,UAAA,EAAY,6BAAA,EAC7B,8BAAC,CAAA,CAAE,UAAA,EAAF,EAAa,CAAA,EAChB,CAAA;AAAA,IAEJ;AAAA;AAEJ,CAAC,CAAA;AAED,MAAM,gBAAA,GAAmB,aAAa,IAAA,CAAK;AAAA,EACzC,MAAA,EAAQ,kBACN,YAAA,CAAa;AAAA,IACX,GAAA,EAAK,mBAAA;AAAA,IACL,IAAA,EAAM;AAAA,MACJ,YAAA,EAAc,eAAA;AAAA,MACd,UAAA,EAAY,aAAA;AAAA,MACZ,QAAA,EAAU,WAAA;AAAA,MACV,kBAAA,EAAoB,qBAAA;AAAA,MACpB,UAAA,EAAY,aAAA;AAAA,MACZ,SAAA,EAAW;AAAA,KACb;AAAA,IACA,SAAS,CAAC;AAAA,MACR,YAAA;AAAA,MACA,UAAA;AAAA,MACA,QAAA;AAAA,MACA,kBAAA;AAAA,MACA,UAAA;AAAA,MACA;AAAA,KACF,KACE,IAAI,mBAAA,CAAoB;AAAA,MACtB,YAAA;AAAA,MACA,UAAA;AAAA,MACA,kBAAA;AAAA,MACA,QAAA;AAAA,MACA,UAAA;AAAA,MACA;AAAA,KACD;AAAA,GACJ;AACL,CAAC,CAAA;AAGD,YAAe,oBAAA,CAAqB;AAAA,EAClC,QAAA,EAAU,gBAAA;AAAA,EACV,KAAA,EAAO,6BAAA;AAAA,EACP,IAAA,sBAAO,eAAA,EAAA,EAAgB,CAAA;AAAA,EACvB,MAAM,EAAE,WAAA,EAAa,MAAM,OAAO,uBAAiB,CAAA,EAAE;AAAA,EACrD,UAAA,EAAY,CAAC,gBAAA,EAAkB,iBAAiB,CAAA;AAAA,EAChD,MAAA,EAAQ;AAAA,IACN,UAAA,EAAY;AAAA;AAEhB,CAAC,CAAA;;;;"}
@@ -1,4 +1,3 @@
1
- import YAML from 'yaml';
2
1
  import { submitGitHubPrToRepo } from './GitHub.esm.js';
3
2
  import { getCatalogFilename } from '../components/helpers.esm.js';
4
3
  import parseGitUrl from 'git-url-parse';
@@ -101,6 +100,7 @@ For more information, read an [overview of the Backstage software catalog](https
101
100
  }
102
101
  async submitPullRequest(options) {
103
102
  const { repositoryUrl, fileContent, title, body } = options;
103
+ const { default: YAML } = await import('yaml');
104
104
  const parseData = YAML.parseAllDocuments(fileContent);
105
105
  for (const document of parseData) {
106
106
  const validationResponse = await this.catalogApi.validateEntity(
@@ -1 +1 @@
1
- {"version":3,"file":"CatalogImportClient.esm.js","sources":["../../src/api/CatalogImportClient.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 { CatalogApi } from '@backstage/catalog-client';\nimport { ConfigApi, DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\nimport {\n GithubIntegration,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { AnalyzeResult, CatalogImportApi } from './CatalogImportApi';\nimport YAML from 'yaml';\nimport { GitHubOptions, submitGitHubPrToRepo } from './GitHub';\nimport { getCatalogFilename } from '../components/helpers';\nimport { AnalyzeLocationResponse } from '@backstage/plugin-catalog-common';\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport parseGitUrl from 'git-url-parse';\nimport { submitAzurePrToRepo } from './AzureDevops';\n\n/**\n * The default implementation of the {@link CatalogImportApi}.\n *\n * @public\n */\nexport class CatalogImportClient implements CatalogImportApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n private readonly scmAuthApi: ScmAuthApi;\n private readonly scmIntegrationsApi: ScmIntegrationRegistry;\n private readonly catalogApi: CatalogApi;\n private readonly configApi: ConfigApi;\n\n constructor(options: {\n discoveryApi: DiscoveryApi;\n scmAuthApi: ScmAuthApi;\n fetchApi: FetchApi;\n scmIntegrationsApi: ScmIntegrationRegistry;\n catalogApi: CatalogApi;\n configApi: ConfigApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.scmAuthApi = options.scmAuthApi;\n this.fetchApi = options.fetchApi;\n this.scmIntegrationsApi = options.scmIntegrationsApi;\n this.catalogApi = options.catalogApi;\n this.configApi = options.configApi;\n }\n\n async analyzeUrl(url: string): Promise<AnalyzeResult> {\n if (\n new URL(url).pathname.match(/\\.ya?ml$/) ||\n new URL(url).searchParams.get('path')?.match(/.ya?ml$/)\n ) {\n const location = await this.catalogApi.addLocation({\n type: 'url',\n target: url,\n dryRun: true,\n });\n\n return {\n type: 'locations',\n locations: [\n {\n exists: location.exists,\n target: location.location.target,\n entities: location.entities.map(e => ({\n kind: e.kind,\n namespace: e.metadata.namespace ?? 'default',\n name: e.metadata.name,\n })),\n },\n ],\n };\n }\n const supportedIntegrations = ['github', 'azure'];\n const foundIntegration = this.scmIntegrationsApi.byUrl(url);\n const iSupported =\n !!foundIntegration &&\n supportedIntegrations.find(it => it === foundIntegration.type);\n if (!iSupported) {\n const catalogFilename = getCatalogFilename(this.configApi);\n\n if (foundIntegration) {\n throw new Error(\n `The ${foundIntegration.title} integration only supports full URLs to ${catalogFilename} files. Did you try to pass in the URL of a directory instead?`,\n );\n }\n throw new Error(\n `This URL was not recognized as a valid git URL because there was no configured integration that matched the given host name. Currently GitHub and Azure DevOps are supported. You could try to paste the full URL to a ${catalogFilename} file instead.`,\n );\n }\n\n const analyzation = await this.analyzeLocation({\n repo: url,\n });\n\n if (analyzation.existingEntityFiles.length > 0) {\n const locations = analyzation.existingEntityFiles.reduce<\n Record<\n string,\n {\n target: string;\n exists?: boolean;\n entities: CompoundEntityRef[];\n }\n >\n >((state, curr) => {\n state[curr.location.target] = {\n target: curr.location.target,\n exists: curr.isRegistered,\n entities: [\n ...(curr.location.target in state\n ? state[curr.location.target].entities\n : []),\n {\n name: curr.entity.metadata.name,\n namespace: curr.entity.metadata.namespace ?? 'default',\n kind: curr.entity.kind,\n },\n ],\n };\n return state;\n }, {});\n return {\n type: 'locations',\n locations: Object.values(locations),\n };\n }\n\n return {\n type: 'repository',\n integrationType: foundIntegration.type,\n url: url,\n generatedEntities: analyzation.generateEntities.map(x => x.entity),\n };\n }\n\n async preparePullRequest(): Promise<{\n title: string;\n body: string;\n }> {\n const appTitle =\n this.configApi.getOptionalString('app.title') ?? 'Backstage';\n const appBaseUrl = this.configApi.getString('app.baseUrl');\n const catalogFilename = getCatalogFilename(this.configApi);\n\n return {\n title: `Add ${catalogFilename} config file`,\n body: `This pull request adds a **Backstage entity metadata file** \\\nto this repository so that the component can be added to the \\\n[${appTitle} software catalog](${appBaseUrl}).\\n\\nAfter this pull request is merged, \\\nthe component will become available.\\n\\nFor more information, read an \\\n[overview of the Backstage software catalog](https://backstage.io/docs/features/software-catalog/).`,\n };\n }\n\n async submitPullRequest(options: {\n repositoryUrl: string;\n fileContent: string;\n title: string;\n body: string;\n }): Promise<{ link: string; location: string }> {\n const { repositoryUrl, fileContent, title, body } = options;\n\n const parseData = YAML.parseAllDocuments(fileContent);\n\n for (const document of parseData) {\n const validationResponse = await this.catalogApi.validateEntity(\n document.toJS(),\n `url:${repositoryUrl}`,\n );\n if (!validationResponse.valid) {\n throw new Error(validationResponse.errors[0].message);\n }\n }\n\n const provider = this.scmIntegrationsApi.byUrl(repositoryUrl);\n\n switch (provider?.type) {\n case 'github': {\n const { config } = provider as GithubIntegration;\n const { name, owner } = parseGitUrl(repositoryUrl);\n const options2: GitHubOptions = {\n githubIntegrationConfig: config,\n repo: name,\n owner: owner,\n repositoryUrl,\n fileContent,\n title,\n body,\n };\n return submitGitHubPrToRepo(options2, this.scmAuthApi, this.configApi);\n }\n case 'azure': {\n return submitAzurePrToRepo(\n {\n repositoryUrl,\n fileContent,\n title,\n body,\n },\n this.scmAuthApi,\n this.configApi,\n );\n }\n default: {\n throw new Error('unimplemented!');\n }\n }\n }\n\n // TODO: this could be part of the catalog api\n private async analyzeLocation(options: {\n repo: string;\n }): Promise<AnalyzeLocationResponse> {\n const response = await this.fetchApi\n .fetch(\n `${await this.discoveryApi.getBaseUrl('catalog')}/analyze-location`,\n {\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n body: JSON.stringify({\n location: { type: 'url', target: options.repo },\n ...(this.configApi.getOptionalString(\n 'catalog.import.entityFilename',\n ) && {\n catalogFilename: this.configApi.getOptionalString(\n 'catalog.import.entityFilename',\n ),\n }),\n }),\n },\n )\n .catch(e => {\n throw new Error(`Failed to generate entity definitions, ${e.message}`);\n });\n if (!response.ok) {\n throw new Error(\n `Failed to generate entity definitions. Received http response ${response.status}: ${response.statusText}`,\n );\n }\n\n const payload = await response.json();\n return payload;\n }\n}\n"],"names":[],"mappings":";;;;;;AAqCO,MAAM,mBAAA,CAAgD;AAAA,EAC1C,YAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,kBAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EAEjB,YAAY,OAAA,EAOT;AACD,IAAA,IAAA,CAAK,eAAe,OAAA,CAAQ,YAAA;AAC5B,IAAA,IAAA,CAAK,aAAa,OAAA,CAAQ,UAAA;AAC1B,IAAA,IAAA,CAAK,WAAW,OAAA,CAAQ,QAAA;AACxB,IAAA,IAAA,CAAK,qBAAqB,OAAA,CAAQ,kBAAA;AAClC,IAAA,IAAA,CAAK,aAAa,OAAA,CAAQ,UAAA;AAC1B,IAAA,IAAA,CAAK,YAAY,OAAA,CAAQ,SAAA;AAAA,EAC3B;AAAA,EAEA,MAAM,WAAW,GAAA,EAAqC;AACpD,IAAA,IACE,IAAI,GAAA,CAAI,GAAG,EAAE,QAAA,CAAS,KAAA,CAAM,UAAU,CAAA,IACtC,IAAI,GAAA,CAAI,GAAG,EAAE,YAAA,CAAa,GAAA,CAAI,MAAM,CAAA,EAAG,KAAA,CAAM,SAAS,CAAA,EACtD;AACA,MAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,UAAA,CAAW,WAAA,CAAY;AAAA,QACjD,IAAA,EAAM,KAAA;AAAA,QACN,MAAA,EAAQ,GAAA;AAAA,QACR,MAAA,EAAQ;AAAA,OACT,CAAA;AAED,MAAA,OAAO;AAAA,QACL,IAAA,EAAM,WAAA;AAAA,QACN,SAAA,EAAW;AAAA,UACT;AAAA,YACE,QAAQ,QAAA,CAAS,MAAA;AAAA,YACjB,MAAA,EAAQ,SAAS,QA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,IAAA,EAAK;AACpC,IAAA,OAAO,OAAA;AAAA,EACT;AACF;;;;"}
1
+ {"version":3,"file":"CatalogImportClient.esm.js","sources":["../../src/api/CatalogImportClient.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 { CatalogApi } from '@backstage/catalog-client';\nimport { ConfigApi, DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\nimport {\n GithubIntegration,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { AnalyzeResult, CatalogImportApi } from './CatalogImportApi';\nimport { GitHubOptions, submitGitHubPrToRepo } from './GitHub';\nimport { getCatalogFilename } from '../components/helpers';\nimport { AnalyzeLocationResponse } from '@backstage/plugin-catalog-common';\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport parseGitUrl from 'git-url-parse';\nimport { submitAzurePrToRepo } from './AzureDevops';\n\n/**\n * The default implementation of the {@link CatalogImportApi}.\n *\n * @public\n */\nexport class CatalogImportClient implements CatalogImportApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n private readonly scmAuthApi: ScmAuthApi;\n private readonly scmIntegrationsApi: ScmIntegrationRegistry;\n private readonly catalogApi: CatalogApi;\n private readonly configApi: ConfigApi;\n\n constructor(options: {\n discoveryApi: DiscoveryApi;\n scmAuthApi: ScmAuthApi;\n fetchApi: FetchApi;\n scmIntegrationsApi: ScmIntegrationRegistry;\n catalogApi: CatalogApi;\n configApi: ConfigApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.scmAuthApi = options.scmAuthApi;\n this.fetchApi = options.fetchApi;\n this.scmIntegrationsApi = options.scmIntegrationsApi;\n this.catalogApi = options.catalogApi;\n this.configApi = options.configApi;\n }\n\n async analyzeUrl(url: string): Promise<AnalyzeResult> {\n if (\n new URL(url).pathname.match(/\\.ya?ml$/) ||\n new URL(url).searchParams.get('path')?.match(/.ya?ml$/)\n ) {\n const location = await this.catalogApi.addLocation({\n type: 'url',\n target: url,\n dryRun: true,\n });\n\n return {\n type: 'locations',\n locations: [\n {\n exists: location.exists,\n target: location.location.target,\n entities: location.entities.map(e => ({\n kind: e.kind,\n namespace: e.metadata.namespace ?? 'default',\n name: e.metadata.name,\n })),\n },\n ],\n };\n }\n const supportedIntegrations = ['github', 'azure'];\n const foundIntegration = this.scmIntegrationsApi.byUrl(url);\n const iSupported =\n !!foundIntegration &&\n supportedIntegrations.find(it => it === foundIntegration.type);\n if (!iSupported) {\n const catalogFilename = getCatalogFilename(this.configApi);\n\n if (foundIntegration) {\n throw new Error(\n `The ${foundIntegration.title} integration only supports full URLs to ${catalogFilename} files. Did you try to pass in the URL of a directory instead?`,\n );\n }\n throw new Error(\n `This URL was not recognized as a valid git URL because there was no configured integration that matched the given host name. Currently GitHub and Azure DevOps are supported. You could try to paste the full URL to a ${catalogFilename} file instead.`,\n );\n }\n\n const analyzation = await this.analyzeLocation({\n repo: url,\n });\n\n if (analyzation.existingEntityFiles.length > 0) {\n const locations = analyzation.existingEntityFiles.reduce<\n Record<\n string,\n {\n target: string;\n exists?: boolean;\n entities: CompoundEntityRef[];\n }\n >\n >((state, curr) => {\n state[curr.location.target] = {\n target: curr.location.target,\n exists: curr.isRegistered,\n entities: [\n ...(curr.location.target in state\n ? state[curr.location.target].entities\n : []),\n {\n name: curr.entity.metadata.name,\n namespace: curr.entity.metadata.namespace ?? 'default',\n kind: curr.entity.kind,\n },\n ],\n };\n return state;\n }, {});\n return {\n type: 'locations',\n locations: Object.values(locations),\n };\n }\n\n return {\n type: 'repository',\n integrationType: foundIntegration.type,\n url: url,\n generatedEntities: analyzation.generateEntities.map(x => x.entity),\n };\n }\n\n async preparePullRequest(): Promise<{\n title: string;\n body: string;\n }> {\n const appTitle =\n this.configApi.getOptionalString('app.title') ?? 'Backstage';\n const appBaseUrl = this.configApi.getString('app.baseUrl');\n const catalogFilename = getCatalogFilename(this.configApi);\n\n return {\n title: `Add ${catalogFilename} config file`,\n body: `This pull request adds a **Backstage entity metadata file** \\\nto this repository so that the component can be added to the \\\n[${appTitle} software catalog](${appBaseUrl}).\\n\\nAfter this pull request is merged, \\\nthe component will become available.\\n\\nFor more information, read an \\\n[overview of the Backstage software catalog](https://backstage.io/docs/features/software-catalog/).`,\n };\n }\n\n async submitPullRequest(options: {\n repositoryUrl: string;\n fileContent: string;\n title: string;\n body: string;\n }): Promise<{ link: string; location: string }> {\n const { repositoryUrl, fileContent, title, body } = options;\n const { default: YAML } = await import('yaml');\n\n const parseData = YAML.parseAllDocuments(fileContent);\n\n for (const document of parseData) {\n const validationResponse = await this.catalogApi.validateEntity(\n document.toJS(),\n `url:${repositoryUrl}`,\n );\n if (!validationResponse.valid) {\n throw new Error(validationResponse.errors[0].message);\n }\n }\n\n const provider = this.scmIntegrationsApi.byUrl(repositoryUrl);\n\n switch (provider?.type) {\n case 'github': {\n const { config } = provider as GithubIntegration;\n const { name, owner } = parseGitUrl(repositoryUrl);\n const options2: GitHubOptions = {\n githubIntegrationConfig: config,\n repo: name,\n owner: owner,\n repositoryUrl,\n fileContent,\n title,\n body,\n };\n return submitGitHubPrToRepo(options2, this.scmAuthApi, this.configApi);\n }\n case 'azure': {\n return submitAzurePrToRepo(\n {\n repositoryUrl,\n fileContent,\n title,\n body,\n },\n this.scmAuthApi,\n this.configApi,\n );\n }\n default: {\n throw new Error('unimplemented!');\n }\n }\n }\n\n // TODO: this could be part of the catalog api\n private async analyzeLocation(options: {\n repo: string;\n }): Promise<AnalyzeLocationResponse> {\n const response = await this.fetchApi\n .fetch(\n `${await this.discoveryApi.getBaseUrl('catalog')}/analyze-location`,\n {\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n body: JSON.stringify({\n location: { type: 'url', target: options.repo },\n ...(this.configApi.getOptionalString(\n 'catalog.import.entityFilename',\n ) && {\n catalogFilename: this.configApi.getOptionalString(\n 'catalog.import.entityFilename',\n ),\n }),\n }),\n },\n )\n .catch(e => {\n throw new Error(`Failed to generate entity definitions, ${e.message}`);\n });\n if (!response.ok) {\n throw new Error(\n `Failed to generate entity definitions. Received http response ${response.status}: ${response.statusText}`,\n );\n }\n\n const payload = await response.json();\n return payload;\n }\n}\n"],"names":[],"mappings":";;;;;AAoCO,MAAM,mBAAA,CAAgD;AAAA,EAC1C,YAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,kBAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EAEjB,YAAY,OAAA,EAOT;AACD,IAAA,IAAA,CAAK,eAAe,OAAA,CAAQ,YAAA;AAC5B,IAAA,IAAA,CAAK,aAAa,OAAA,CAAQ,UAAA;AAC1B,IAAA,IAAA,CAAK,WAAW,OAAA,CAAQ,QAAA;AACxB,IAAA,IAAA,CAAK,qBAAqB,OAAA,CAAQ,kBAAA;AAClC,IAAA,IAAA,CAAK,aAAa,OAAA,CAAQ,UAAA;AAC1B,IAAA,IAAA,CAAK,YAAY,OAAA,CAAQ,SAAA;AAAA,EAC3B;AAAA,EAEA,MAAM,WAAW,GAAA,EAAqC;AACpD,IAAA,IACE,IAAI,GAAA,CAAI,GAAG,EAAE,QAAA,CAAS,KAAA,CAAM,UAAU,CAAA,IACtC,IAAI,GAAA,CAAI,GAAG,EAAE,YAAA,CAAa,GAAA,CAAI,MAAM,CAAA,EAAG,KAAA,CAAM,SAAS,CAAA,EACtD;AACA,MAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,UAAA,CAAW,WAAA,CAAY;AAAA,QACjD,IAAA,EAAM,KAAA;AAAA,QACN,MAAA,EAAQ,GAA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,CAAA,CAAE,CAAA;AAAA,IACvE,CAAC,CAAA;AACH,IAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,8DAAA,EAAiE,QAAA,CAAS,MAAM,CAAA,EAAA,EAAK,SAAS,UAAU,CAAA;AAAA,OAC1G;AAAA,IACF;AAEA,IAAA,MAAM,OAAA,GAAU,MAAM,QAAA,CAAS,IAAA,EAAK;AACpC,IAAA,OAAO,OAAA;AAAA,EACT;AACF;;;;"}
@@ -24,7 +24,6 @@ import '../EntityListComponent/EntityListComponent.esm.js';
24
24
  import 'react';
25
25
  import 'react-hook-form';
26
26
  import '../../api/CatalogImportApi.esm.js';
27
- import 'yaml';
28
27
  import '@octokit/rest';
29
28
  import 'js-base64';
30
29
  import 'git-url-parse';
@@ -33,6 +32,7 @@ import '@material-ui/lab/Autocomplete';
33
32
  import '@material-ui/core/Card';
34
33
  import '@material-ui/core/CardContent';
35
34
  import '@material-ui/core/CardHeader';
35
+ import 'yaml';
36
36
  import 'lodash';
37
37
  import '../StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.esm.js';
38
38
  import '@material-ui/core/ListItem';
@@ -5,7 +5,6 @@ import { useTranslationRef } from '@backstage/frontend-plugin-api';
5
5
  import Chip from '@material-ui/core/Chip';
6
6
  import Typography from '@material-ui/core/Typography';
7
7
  import { catalogImportApiRef } from '../../api/CatalogImportApi.esm.js';
8
- import 'yaml';
9
8
  import '@octokit/rest';
10
9
  import 'js-base64';
11
10
  import 'git-url-parse';
@@ -1 +1 @@
1
- {"version":3,"file":"ImportInfoCard.esm.js","sources":["../../../src/components/ImportInfoCard/ImportInfoCard.tsx"],"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 { InfoCard } from '@backstage/core-components';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport Chip from '@material-ui/core/Chip';\nimport Typography from '@material-ui/core/Typography';\n\nimport { catalogImportApiRef } from '../../api';\nimport { useCatalogFilename } from '../../hooks';\nimport { catalogImportTranslationRef } from '../../translation';\n\n/**\n * Props for {@link ImportInfoCard}.\n *\n * @public\n */\nexport interface ImportInfoCardProps {\n exampleLocationUrl?: string;\n exampleRepositoryUrl?: string;\n}\n\n/**\n * Shows information about the import process.\n *\n * @public\n */\nexport const ImportInfoCard = (props: ImportInfoCardProps) => {\n const {\n exampleLocationUrl = 'https://github.com/backstage/backstage/blob/master/catalog-info.yaml',\n exampleRepositoryUrl = 'https://github.com/backstage/backstage',\n } = props;\n\n const { t } = useTranslationRef(catalogImportTranslationRef);\n const configApi = useApi(configApiRef);\n const appTitle = configApi.getOptionalString('app.title') || 'Backstage';\n const catalogImportApi = useApi(catalogImportApiRef);\n\n const hasGithubIntegration = configApi.has('integrations.github');\n\n const catalogFilename = useCatalogFilename();\n\n return (\n <InfoCard\n title={t('importInfoCard.title')}\n titleTypographyProps={{ component: 'h3' }}\n deepLink={{\n title: t('importInfoCard.deepLinkTitle'),\n link: 'https://backstage.io/docs/features/software-catalog/',\n }}\n >\n <Typography variant=\"body2\" paragraph>\n {t('importInfoCard.linkDescription', { appTitle })}\n </Typography>\n <Typography component=\"h4\" variant=\"h6\">\n {t('importInfoCard.fileLinkTitle')}\n </Typography>\n <Typography variant=\"subtitle2\" color=\"textSecondary\" paragraph>\n {t('importInfoCard.examplePrefix')}\n <code>{exampleLocationUrl}</code>\n </Typography>\n <Typography variant=\"body2\" paragraph>\n {t('importInfoCard.fileLinkDescription', { appTitle })}\n </Typography>\n {hasGithubIntegration && (\n <>\n <Typography component=\"h4\" variant=\"h6\">\n {t('importInfoCard.githubIntegration.title')}\n <Chip\n label={t('importInfoCard.githubIntegration.label')}\n variant=\"outlined\"\n size=\"small\"\n style={{ marginLeft: 8, marginBottom: 0 }}\n />\n </Typography>\n <Typography variant=\"subtitle2\" color=\"textSecondary\" paragraph>\n {t('importInfoCard.examplePrefix')}\n <code>{exampleRepositoryUrl}</code>\n </Typography>\n <Typography variant=\"body2\" paragraph>\n {t('importInfoCard.exampleDescription', {\n catalogFilename: <code>{catalogFilename}</code>,\n appTitle,\n })}\n </Typography>\n {catalogImportApi.preparePullRequest && (\n <Typography variant=\"body2\" paragraph>\n {t('importInfoCard.preparePullRequestDescription', {\n catalogFilename: <code>{catalogFilename}</code>,\n appTitle,\n })}\n </Typography>\n )}\n </>\n )}\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAyCO,MAAM,cAAA,GAAiB,CAAC,KAAA,KAA+B;AAC5D,EAAA,MAAM;AAAA,IACJ,kBAAA,GAAqB,sEAAA;AAAA,IACrB,oBAAA,GAAuB;AAAA,GACzB,GAAI,KAAA;AAEJ,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,2BAA2B,CAAA;AAC3D,EAAA,MAAM,SAAA,GAAY,OAAO,YAAY,CAAA;AACrC,EAAA,MAAM,QAAA,GAAW,SAAA,CAAU,iBAAA,CAAkB,WAAW,CAAA,IAAK,WAAA;AAC7D,EAAA,MAAM,gBAAA,GAAmB,OAAO,mBAAmB,CAAA;AAEnD,EAAA,MAAM,oBAAA,GAAuB,SAAA,CAAU,GAAA,CAAI,qBAAqB,CAAA;AAEhE,EAAA,MAAM,kBAAkB,kBAAA,EAAmB;AAE3C,EAAA,uBACE,IAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,EAAE,sBAAsB,CAAA;AAAA,MAC/B,oBAAA,EAAsB,EAAE,SAAA,EAA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A;AAAE;AAAA;AAC1C,WAAA,EACF,CAAA;AAAA,+BACC,UAAA,EAAA,EAAW,OAAA,EAAQ,aAAY,KAAA,EAAM,eAAA,EAAgB,WAAS,IAAA,EAC5D,QAAA,EAAA;AAAA,YAAA,CAAA,CAAE,8BAA8B,CAAA;AAAA,4BACjC,GAAA,CAAC,UAAM,QAAA,EAAA,oBAAA,EAAqB;AAAA,WAAA,EAC9B,CAAA;AAAA,8BACC,UAAA,EAAA,EAAW,OAAA,EAAQ,SAAQ,SAAA,EAAS,IAAA,EAClC,YAAE,mCAAA,EAAqC;AAAA,YACtC,eAAA,kBAAiB,GAAA,CAAC,MAAA,EAAA,EAAM,QAAA,EAAA,eAAA,EAAgB,CAAA;AAAA,YACxC;AAAA,WACD,CAAA,EACH,CAAA;AAAA,UACC,gBAAA,CAAiB,sCAChB,GAAA,CAAC,UAAA,EAAA,EAAW,SAAQ,OAAA,EAAQ,SAAA,EAAS,IAAA,EAClC,QAAA,EAAA,CAAA,CAAE,8CAAA,EAAgD;AAAA,YACjD,eAAA,kBAAiB,GAAA,CAAC,MAAA,EAAA,EAAM,QAAA,EAAA,eAAA,EAAgB,CAAA;AAAA,YACxC;AAAA,WACD,CAAA,EACH;AAAA,SAAA,EAEJ;AAAA;AAAA;AAAA,GAEJ;AAEJ;;;;"}
1
+ {"version":3,"file":"ImportInfoCard.esm.js","sources":["../../../src/components/ImportInfoCard/ImportInfoCard.tsx"],"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 { InfoCard } from '@backstage/core-components';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport Chip from '@material-ui/core/Chip';\nimport Typography from '@material-ui/core/Typography';\n\nimport { catalogImportApiRef } from '../../api';\nimport { useCatalogFilename } from '../../hooks';\nimport { catalogImportTranslationRef } from '../../translation';\n\n/**\n * Props for {@link ImportInfoCard}.\n *\n * @public\n */\nexport interface ImportInfoCardProps {\n exampleLocationUrl?: string;\n exampleRepositoryUrl?: string;\n}\n\n/**\n * Shows information about the import process.\n *\n * @public\n */\nexport const ImportInfoCard = (props: ImportInfoCardProps) => {\n const {\n exampleLocationUrl = 'https://github.com/backstage/backstage/blob/master/catalog-info.yaml',\n exampleRepositoryUrl = 'https://github.com/backstage/backstage',\n } = props;\n\n const { t } = useTranslationRef(catalogImportTranslationRef);\n const configApi = useApi(configApiRef);\n const appTitle = configApi.getOptionalString('app.title') || 'Backstage';\n const catalogImportApi = useApi(catalogImportApiRef);\n\n const hasGithubIntegration = configApi.has('integrations.github');\n\n const catalogFilename = useCatalogFilename();\n\n return (\n <InfoCard\n title={t('importInfoCard.title')}\n titleTypographyProps={{ component: 'h3' }}\n deepLink={{\n title: t('importInfoCard.deepLinkTitle'),\n link: 'https://backstage.io/docs/features/software-catalog/',\n }}\n >\n <Typography variant=\"body2\" paragraph>\n {t('importInfoCard.linkDescription', { appTitle })}\n </Typography>\n <Typography component=\"h4\" variant=\"h6\">\n {t('importInfoCard.fileLinkTitle')}\n </Typography>\n <Typography variant=\"subtitle2\" color=\"textSecondary\" paragraph>\n {t('importInfoCard.examplePrefix')}\n <code>{exampleLocationUrl}</code>\n </Typography>\n <Typography variant=\"body2\" paragraph>\n {t('importInfoCard.fileLinkDescription', { appTitle })}\n </Typography>\n {hasGithubIntegration && (\n <>\n <Typography component=\"h4\" variant=\"h6\">\n {t('importInfoCard.githubIntegration.title')}\n <Chip\n label={t('importInfoCard.githubIntegration.label')}\n variant=\"outlined\"\n size=\"small\"\n style={{ marginLeft: 8, marginBottom: 0 }}\n />\n </Typography>\n <Typography variant=\"subtitle2\" color=\"textSecondary\" paragraph>\n {t('importInfoCard.examplePrefix')}\n <code>{exampleRepositoryUrl}</code>\n </Typography>\n <Typography variant=\"body2\" paragraph>\n {t('importInfoCard.exampleDescription', {\n catalogFilename: <code>{catalogFilename}</code>,\n appTitle,\n })}\n </Typography>\n {catalogImportApi.preparePullRequest && (\n <Typography variant=\"body2\" paragraph>\n {t('importInfoCard.preparePullRequestDescription', {\n catalogFilename: <code>{catalogFilename}</code>,\n appTitle,\n })}\n </Typography>\n )}\n </>\n )}\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAyCO,MAAM,cAAA,GAAiB,CAAC,KAAA,KAA+B;AAC5D,EAAA,MAAM;AAAA,IACJ,kBAAA,GAAqB,sEAAA;AAAA,IACrB,oBAAA,GAAuB;AAAA,GACzB,GAAI,KAAA;AAEJ,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,2BAA2B,CAAA;AAC3D,EAAA,MAAM,SAAA,GAAY,OAAO,YAAY,CAAA;AACrC,EAAA,MAAM,QAAA,GAAW,SAAA,CAAU,iBAAA,CAAkB,WAAW,CAAA,IAAK,WAAA;AAC7D,EAAA,MAAM,gBAAA,GAAmB,OAAO,mBAAmB,CAAA;AAEnD,EAAA,MAAM,oBAAA,GAAuB,SAAA,CAAU,GAAA,CAAI,qBAAqB,CAAA;AAEhE,EAAA,MAAM,kBAAkB,kBAAA,EAAmB;AAE3C,EAAA,uBACE,IAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,EAAE,sBAAsB,CAAA;AAAA,MAC/B,oBAAA,EAAsB,EAAE,SAAA,EAAW,IAAA,EAAK;AAAA,MACxC,QAAA,EAAU;AAAA,QACR,KAAA,EAAO,EAAE,8BAA8B,CAAA;AAAA,QACvC,IAAA,EAAM;AAAA,OACR;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAA,GAAA,CA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CAAE,8BAA8B,CAAA;AAAA,4BACjC,GAAA,CAAC,UAAM,QAAA,EAAA,oBAAA,EAAqB;AAAA,WAAA,EAC9B,CAAA;AAAA,8BACC,UAAA,EAAA,EAAW,OAAA,EAAQ,SAAQ,SAAA,EAAS,IAAA,EAClC,YAAE,mCAAA,EAAqC;AAAA,YACtC,eAAA,kBAAiB,GAAA,CAAC,MAAA,EAAA,EAAM,QAAA,EAAA,eAAA,EAAgB,CAAA;AAAA,YACxC;AAAA,WACD,CAAA,EACH,CAAA;AAAA,UACC,gBAAA,CAAiB,sCAChB,GAAA,CAAC,UAAA,EAAA,EAAW,SAAQ,OAAA,EAAQ,SAAA,EAAS,IAAA,EAClC,QAAA,EAAA,CAAA,CAAE,8CAAA,EAAgD;AAAA,YACjD,eAAA,kBAAiB,GAAA,CAAC,MAAA,EAAA,EAAM,QAAA,EAAA,eAAA,EAAgB,CAAA;AAAA,YACxC;AAAA,WACD,CAAA,EACH;AAAA,SAAA,EAEJ;AAAA;AAAA;AAAA,GAEJ;AAEJ;;;;"}
@@ -9,7 +9,6 @@ import Stepper from '@material-ui/core/Stepper';
9
9
  import { makeStyles } from '@material-ui/core/styles';
10
10
  import { useMemo } from 'react';
11
11
  import { catalogImportApiRef } from '../../api/CatalogImportApi.esm.js';
12
- import 'yaml';
13
12
  import '@octokit/rest';
14
13
  import 'js-base64';
15
14
  import 'git-url-parse';
@@ -1 +1 @@
1
- {"version":3,"file":"ImportStepper.esm.js","sources":["../../../src/components/ImportStepper/ImportStepper.tsx"],"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 { InfoCard, InfoCardVariants } from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { TranslationFunction } from '@backstage/core-plugin-api/alpha';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { catalogImportTranslationRef } from '@backstage/plugin-catalog-import/alpha';\nimport Step from '@material-ui/core/Step';\nimport StepContent from '@material-ui/core/StepContent';\nimport Stepper from '@material-ui/core/Stepper';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { useMemo } from 'react';\n\nimport { catalogImportApiRef } from '../../api';\nimport { ImportFlows, ImportState, useImportState } from '../useImportState';\nimport {\n defaultGenerateStepper,\n defaultStepper,\n StepConfiguration,\n StepperProvider,\n} from './defaults';\n\nconst useStyles = makeStyles(() => ({\n stepperRoot: {\n padding: 0,\n },\n}));\n\n/**\n * Props for {@link ImportStepper}.\n *\n * @public\n */\nexport interface ImportStepperProps {\n initialUrl?: string;\n generateStepper?: (\n flow: ImportFlows,\n defaults: StepperProvider,\n t: TranslationFunction<typeof catalogImportTranslationRef.T>,\n ) => StepperProvider;\n variant?: InfoCardVariants;\n}\n\n/**\n * The stepper that holds the different import stages.\n *\n * @public\n */\nexport const ImportStepper = (props: ImportStepperProps) => {\n const { t } = useTranslationRef(catalogImportTranslationRef);\n const {\n initialUrl,\n generateStepper = defaultGenerateStepper,\n variant,\n } = props;\n\n const catalogImportApi = useApi(catalogImportApiRef);\n const classes = useStyles();\n const state = useImportState({ initialUrl });\n\n const states = useMemo<StepperProvider>(\n () => generateStepper(state.activeFlow, defaultStepper, t),\n [generateStepper, state.activeFlow, t],\n );\n\n const render = (step: StepConfiguration) => {\n return (\n <Step>\n {step.stepLabel}\n <StepContent>{step.content}</StepContent>\n </Step>\n );\n };\n\n return (\n <InfoCard variant={variant}>\n <Stepper\n classes={{ root: classes.stepperRoot }}\n activeStep={state.activeStepNumber}\n orientation=\"vertical\"\n >\n {render(\n states.analyze(\n state as Extract<ImportState, { activeState: 'analyze' }>,\n { apis: { catalogImportApi }, t },\n ),\n )}\n {render(\n states.prepare(\n state as Extract<ImportState, { activeState: 'prepare' }>,\n { apis: { catalogImportApi }, t },\n ),\n )}\n {render(\n states.review(\n state as Extract<ImportState, { activeState: 'review' }>,\n { apis: { catalogImportApi }, t },\n ),\n )}\n {render(\n states.finish(\n state as Extract<ImportState, { activeState: 'finish' }>,\n { apis: { catalogImportApi }, t },\n ),\n )}\n </Stepper>\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAoCA,MAAM,SAAA,GAAY,WAAW,OAAO;AAAA,EAClC,WAAA,EAAa;AAAA,IACX,OAAA,EAAS;AAAA;AAEb,CAAA,CAAE,CAAA;AAsBK,MAAM,aAAA,GAAgB,CAAC,KAAA,KAA8B;AAC1D,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,2BAA2B,CAAA;AAC3D,EAAA,MAAM;AAAA,IACJ,UAAA;AAAA,IACA,eAAA,GAAkB,sBAAA;AAAA,IAClB;AAAA,GACF,GAAI,KAAA;AAEJ,EAAA,MAAM,gBAAA,GAAmB,OAAO,mBAAmB,CAAA;AACnD,EAAA,MAAM,UAAU,SAAA,EAAU;AAC1B,EAAA,MAAM,KAAA,GAAQ,cAAA,CAAe,EAAE,UAAA,EAAY,CAAA;AAE3C,EAAA,MAAM,MAAA,GAAS,OAAA;AAAA,IACb,MAAM,eAAA,CAAgB,KAAA,CAAM,UAAA,EAAY,gBAAgB,CAAC,CAAA;AAAA,IACzD,CAAC,eAAA,EAAiB,KAAA,CAAM,UAAA,EAAY,CAAC;AAAA,GACvC;AAEA,EAAA,MAAM,MAAA,GAAS,CAAC,IAAA,KAA4B;AAC1C,IAAA,4BACG,IAAA,EAAA,EACE,QAAA,EAAA;AAAA,MAAA,IAAA,CAAK,SAAA;AAAA,sBACN,GAAA,CAAC,WAAA,EAAA,EAAa,QAAA,EAAA,IAAA,CAAK,OAAA,EAAQ;AAAA,KAAA,EAC7B,CAAA;AAAA,EAEJ,CAAA;AAEA,EAAA,uBACE,GAAA,CAAC,YAAS,OAAA,EACR,QAAA,kBAAA,IAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACC,OAAA,EAAS,EAAE,IAAA,EAAM,OAAA,CAAQ,WAAA,EAAY;AAAA,MACrC,YAAY,KAAA,CAAM,gBAAA;AAAA,MAClB,WAAA,EAAY,UAAA;AAAA,MAEX,QAAA,EAAA;AAAA,QAAA,MAAA;AAAA,UACC,MAAA,CAAO,OAAA;AAAA,YACL,KAAA;AAAA,YACA,EAAE,IAAA,EAAM,EAAE,gBAAA,IAAoB,CAAA;AAAE;AAClC,SACF;AAAA,QACC,MAAA;AAAA,UACC,MAAA,CAAO,OAAA;AAAA,YACL,KAAA;AAAA,YACA,EAAE,IAAA,EAAM,EAAE,gBAAA,IAAoB,CAAA;AAAE;AAClC,SACF;AAAA,QACC,MAAA;AAAA,UACC,MAAA,CAAO,MAAA;AAAA,YACL,KAAA;AAAA,YACA,EAAE,IAAA,EAAM,EAAE,gBAAA,IAAoB,CAAA;AAAE;AAClC,SACF;AAAA,QACC,MAAA;AAAA,UACC,MAAA,CAAO,MAAA;AAAA,YACL,KAAA;AAAA,YACA,EAAE,IAAA,EAAM,EAAE,gBAAA,IAAoB,CAAA;AAAE;AAClC;AACF;AAAA;AAAA,GACF,EACF,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"ImportStepper.esm.js","sources":["../../../src/components/ImportStepper/ImportStepper.tsx"],"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 { InfoCard, InfoCardVariants } from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { TranslationFunction } from '@backstage/core-plugin-api/alpha';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { catalogImportTranslationRef } from '@backstage/plugin-catalog-import/alpha';\nimport Step from '@material-ui/core/Step';\nimport StepContent from '@material-ui/core/StepContent';\nimport Stepper from '@material-ui/core/Stepper';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { useMemo } from 'react';\n\nimport { catalogImportApiRef } from '../../api';\nimport { ImportFlows, ImportState, useImportState } from '../useImportState';\nimport {\n defaultGenerateStepper,\n defaultStepper,\n StepConfiguration,\n StepperProvider,\n} from './defaults';\n\nconst useStyles = makeStyles(() => ({\n stepperRoot: {\n padding: 0,\n },\n}));\n\n/**\n * Props for {@link ImportStepper}.\n *\n * @public\n */\nexport interface ImportStepperProps {\n initialUrl?: string;\n generateStepper?: (\n flow: ImportFlows,\n defaults: StepperProvider,\n t: TranslationFunction<typeof catalogImportTranslationRef.T>,\n ) => StepperProvider;\n variant?: InfoCardVariants;\n}\n\n/**\n * The stepper that holds the different import stages.\n *\n * @public\n */\nexport const ImportStepper = (props: ImportStepperProps) => {\n const { t } = useTranslationRef(catalogImportTranslationRef);\n const {\n initialUrl,\n generateStepper = defaultGenerateStepper,\n variant,\n } = props;\n\n const catalogImportApi = useApi(catalogImportApiRef);\n const classes = useStyles();\n const state = useImportState({ initialUrl });\n\n const states = useMemo<StepperProvider>(\n () => generateStepper(state.activeFlow, defaultStepper, t),\n [generateStepper, state.activeFlow, t],\n );\n\n const render = (step: StepConfiguration) => {\n return (\n <Step>\n {step.stepLabel}\n <StepContent>{step.content}</StepContent>\n </Step>\n );\n };\n\n return (\n <InfoCard variant={variant}>\n <Stepper\n classes={{ root: classes.stepperRoot }}\n activeStep={state.activeStepNumber}\n orientation=\"vertical\"\n >\n {render(\n states.analyze(\n state as Extract<ImportState, { activeState: 'analyze' }>,\n { apis: { catalogImportApi }, t },\n ),\n )}\n {render(\n states.prepare(\n state as Extract<ImportState, { activeState: 'prepare' }>,\n { apis: { catalogImportApi }, t },\n ),\n )}\n {render(\n states.review(\n state as Extract<ImportState, { activeState: 'review' }>,\n { apis: { catalogImportApi }, t },\n ),\n )}\n {render(\n states.finish(\n state as Extract<ImportState, { activeState: 'finish' }>,\n { apis: { catalogImportApi }, t },\n ),\n )}\n </Stepper>\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAoCA,MAAM,SAAA,GAAY,WAAW,OAAO;AAAA,EAClC,WAAA,EAAa;AAAA,IACX,OAAA,EAAS;AAAA;AAEb,CAAA,CAAE,CAAA;AAsBK,MAAM,aAAA,GAAgB,CAAC,KAAA,KAA8B;AAC1D,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,2BAA2B,CAAA;AAC3D,EAAA,MAAM;AAAA,IACJ,UAAA;AAAA,IACA,eAAA,GAAkB,sBAAA;AAAA,IAClB;AAAA,GACF,GAAI,KAAA;AAEJ,EAAA,MAAM,gBAAA,GAAmB,OAAO,mBAAmB,CAAA;AACnD,EAAA,MAAM,UAAU,SAAA,EAAU;AAC1B,EAAA,MAAM,KAAA,GAAQ,cAAA,CAAe,EAAE,UAAA,EAAY,CAAA;AAE3C,EAAA,MAAM,MAAA,GAAS,OAAA;AAAA,IACb,MAAM,eAAA,CAAgB,KAAA,CAAM,UAAA,EAAY,gBAAgB,CAAC,CAAA;AAAA,IACzD,CAAC,eAAA,EAAiB,KAAA,CAAM,UAAA,EAAY,CAAC;AAAA,GACvC;AAEA,EAAA,MAAM,MAAA,GAAS,CAAC,IAAA,KAA4B;AAC1C,IAAA,4BACG,IAAA,EAAA,EACE,QAAA,EAAA;AAAA,MAAA,IAAA,CAAK,SAAA;AAAA,sBACN,GAAA,CAAC,WAAA,EAAA,EAAa,QAAA,EAAA,IAAA,CAAK,OAAA,EAAQ;AAAA,KAAA,EAC7B,CAAA;AAAA,EAEJ,CAAA;AAEA,EAAA,uBACE,GAAA,CAAC,YAAS,OAAA,EACR,QAAA,kBAAA,IAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACC,OAAA,EAAS,EAAE,IAAA,EAAM,OAAA,CAAQ,WAAA,EAAY;AAAA,MACrC,YAAY,KAAA,CAAM,gBAAA;AAAA,MAClB,WAAA,EAAY,UAAA;AAAA,MAEX,QAAA,EAAA;AAAA,QAAA,MAAA;AAAA,UACC,MAAA,CAAO,OAAA;AAAA,YACL,KAAA;AAAA,YACA,EAAE,IAAA,EAAM,EAAE,gBAAA,IAAoB,CAAA;AAAE;AAClC,SACF;AAAA,QACC,MAAA;AAAA,UACC,MAAA,CAAO,OAAA;AAAA,YACL,KAAA;AAAA,YACA,EAAE,IAAA,EAAM,EAAE,gBAAA,IAAoB,CAAA;AAAE;AAClC,SACF;AAAA,QACC,MAAA;AAAA,UACC,MAAA,CAAO,MAAA;AAAA,YACL,KAAA;AAAA,YACA,EAAE,IAAA,EAAM,EAAE,gBAAA,IAAoB,CAAA;AAAE;AAClC,SACF;AAAA,QACC,MAAA;AAAA,UACC,MAAA,CAAO,MAAA;AAAA,YACL,KAAA;AAAA,YACA,EAAE,IAAA,EAAM,EAAE,gBAAA,IAAoB,CAAA;AAAE;AAClC;AACF;AAAA;AAAA,GACF,EACF,CAAA;AAEJ;;;;"}
@@ -7,7 +7,6 @@ import TextField from '@material-ui/core/TextField';
7
7
  import { useState, useCallback } from 'react';
8
8
  import { useForm } from 'react-hook-form';
9
9
  import { catalogImportApiRef } from '../../api/CatalogImportApi.esm.js';
10
- import 'yaml';
11
10
  import '@octokit/rest';
12
11
  import { asInputRef } from '../helpers.esm.js';
13
12
  import 'js-base64';
@@ -1 +1 @@
1
- {"version":3,"file":"StepInitAnalyzeUrl.esm.js","sources":["../../../src/components/StepInitAnalyzeUrl/StepInitAnalyzeUrl.tsx"],"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 { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Grid from '@material-ui/core/Grid';\nimport TextField from '@material-ui/core/TextField';\nimport { useCallback, useState } from 'react';\nimport { useForm } from 'react-hook-form';\n\nimport { AnalyzeResult, catalogImportApiRef } from '../../api';\nimport { catalogImportTranslationRef } from '../../translation';\nimport { NextButton } from '../Buttons';\nimport { asInputRef } from '../helpers';\nimport { ImportFlows, PrepareResult } from '../useImportState';\n\ntype FormData = {\n url: string;\n};\n\n/**\n * Props for {@link StepInitAnalyzeUrl}.\n *\n * @public\n */\nexport interface StepInitAnalyzeUrlProps {\n onAnalysis: (\n flow: ImportFlows,\n url: string,\n result: AnalyzeResult,\n opts?: { prepareResult?: PrepareResult },\n ) => void;\n disablePullRequest?: boolean;\n analysisUrl?: string;\n exampleLocationUrl?: string;\n}\n\n/**\n * A form that lets the user input a url and analyze it for existing locations or potential entities.\n *\n * @param onAnalysis - is called when the analysis was successful\n * @param analysisUrl - a url that can be used as a default value\n * @param disablePullRequest - if true, repositories without entities will abort the wizard\n * @public\n */\nexport const StepInitAnalyzeUrl = (props: StepInitAnalyzeUrlProps) => {\n const { t } = useTranslationRef(catalogImportTranslationRef);\n const {\n onAnalysis,\n analysisUrl = '',\n disablePullRequest = false,\n exampleLocationUrl = 'https://github.com/backstage/backstage/blob/master/catalog-info.yaml',\n } = props;\n\n const errorApi = useApi(errorApiRef);\n const catalogImportApi = useApi(catalogImportApiRef);\n\n const {\n register,\n handleSubmit,\n formState: { errors },\n watch,\n } = useForm<FormData>({\n mode: 'onTouched',\n defaultValues: {\n url: analysisUrl,\n },\n });\n\n const [submitted, setSubmitted] = useState(false);\n const [error, setError] = useState<string | undefined>(undefined);\n\n const handleResult = useCallback(\n async ({ url }: FormData) => {\n setSubmitted(true);\n\n try {\n const analysisResult = await catalogImportApi.analyzeUrl(url);\n\n switch (analysisResult.type) {\n case 'repository':\n if (\n !disablePullRequest &&\n analysisResult.generatedEntities.length > 0\n ) {\n onAnalysis('no-location', url, analysisResult);\n } else {\n setError(t('stepInitAnalyzeUrl.error.repository'));\n setSubmitted(false);\n }\n break;\n\n case 'locations': {\n if (analysisResult.locations.length === 1) {\n onAnalysis('single-location', url, analysisResult, {\n prepareResult: analysisResult,\n });\n } else if (analysisResult.locations.length > 1) {\n onAnalysis('multiple-locations', url, analysisResult);\n } else {\n setError(t('stepInitAnalyzeUrl.error.locations'));\n setSubmitted(false);\n }\n break;\n }\n\n default: {\n const err = t('stepInitAnalyzeUrl.error.default', {\n type: (analysisResult as any).type,\n });\n setError(err);\n setSubmitted(false);\n\n errorApi.post(new Error(err));\n break;\n }\n }\n } catch (e: any) {\n setError(e?.body?.error?.message ?? e.message);\n setSubmitted(false);\n }\n },\n [catalogImportApi, disablePullRequest, errorApi, onAnalysis, t],\n );\n\n return (\n <form onSubmit={handleSubmit(handleResult)}>\n <TextField\n {...asInputRef(\n register('url', {\n required: true,\n validate: {\n httpsValidator: (value: any) =>\n (typeof value === 'string' &&\n value.match(/^http[s]?:\\/\\//) !== null) ||\n t('stepInitAnalyzeUrl.error.url'),\n },\n }),\n )}\n fullWidth\n id=\"url\"\n label=\"URL\"\n placeholder={exampleLocationUrl}\n helperText={t('stepInitAnalyzeUrl.urlHelperText')}\n margin=\"normal\"\n variant=\"outlined\"\n error={Boolean(errors.url)}\n required\n />\n {errors.url && (\n <FormHelperText error>{errors.url.message}</FormHelperText>\n )}\n {error && <FormHelperText error>{error}</FormHelperText>}\n <Grid container spacing={0}>\n <NextButton\n disabled={Boolean(errors.url) || !watch('url')}\n loading={submitted}\n type=\"submit\"\n >\n {t('stepInitAnalyzeUrl.nextButtonText')}\n </NextButton>\n </Grid>\n </form>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA2DO,MAAM,kBAAA,GAAqB,CAAC,KAAA,KAAmC;AACpE,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,2BAA2B,CAAA;AAC3D,EAAA,MAAM;AAAA,IACJ,UAAA;AAAA,IACA,WAAA,GAAc,EAAA;AAAA,IACd,kBAAA,GAAqB,KAAA;AAAA,IACrB,kBAAA,GAAqB;AAAA,GACvB,GAAI,KAAA;AAEJ,EAAA,MAAM,QAAA,GAAW,OAAO,WAAW,CAAA;AACnC,EAAA,MAAM,gBAAA,GAAmB,OAAO,mBAAmB,CAAA;AAEnD,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,YAAA;AAAA,IACA,SAAA,EAAW,EAAE,MAAA,EAAO;AAAA,IACpB;AAAA,MACE,OAAA,CAAkB;AAAA,IACpB,IAAA,EAAM,WAAA;AAAA,IACN,aAAA,EAAe;AAAA,MACb,GAAA,EAAK;AAAA;AACP,GACD,CAAA;AAED,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,SAAS,KAAK,CAAA;AAChD,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAA6B,MAAS,CAAA;AAEhE,EAAA,MAAM,YAAA,GAAe,WAAA;AAAA,IACnB,OAAO,EAAE,GAAA,EAAI,KAAgB;AAC3B,MAAA,YAAA,CAAa,IAAI,CAAA;AAEjB,MAAA,IAAI;AACF,QAAA,MAAM,cAAA,GAAiB,MAAM,gBAAA,CAAiB,UAAA,CAAW,GAAG,CAAA;AAE5D,QAAA,QAAQ,eAAe,IAAA;AAAM,UAC3B,KAAK,YAAA;AACH,YAAA,IACE,CAAC,kBAAA,IACD,cAAA,CAAe,iBAAA,CAAkB,SAAS,C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,EAAS,SAAA;AAAA,QACT,IAAA,EAAK,QAAA;AAAA,QAEJ,YAAE,mCAAmC;AAAA;AAAA,KACxC,EACF;AAAA,GAAA,EACF,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"StepInitAnalyzeUrl.esm.js","sources":["../../../src/components/StepInitAnalyzeUrl/StepInitAnalyzeUrl.tsx"],"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 { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Grid from '@material-ui/core/Grid';\nimport TextField from '@material-ui/core/TextField';\nimport { useCallback, useState } from 'react';\nimport { useForm } from 'react-hook-form';\n\nimport { AnalyzeResult, catalogImportApiRef } from '../../api';\nimport { catalogImportTranslationRef } from '../../translation';\nimport { NextButton } from '../Buttons';\nimport { asInputRef } from '../helpers';\nimport { ImportFlows, PrepareResult } from '../useImportState';\n\ntype FormData = {\n url: string;\n};\n\n/**\n * Props for {@link StepInitAnalyzeUrl}.\n *\n * @public\n */\nexport interface StepInitAnalyzeUrlProps {\n onAnalysis: (\n flow: ImportFlows,\n url: string,\n result: AnalyzeResult,\n opts?: { prepareResult?: PrepareResult },\n ) => void;\n disablePullRequest?: boolean;\n analysisUrl?: string;\n exampleLocationUrl?: string;\n}\n\n/**\n * A form that lets the user input a url and analyze it for existing locations or potential entities.\n *\n * @param onAnalysis - is called when the analysis was successful\n * @param analysisUrl - a url that can be used as a default value\n * @param disablePullRequest - if true, repositories without entities will abort the wizard\n * @public\n */\nexport const StepInitAnalyzeUrl = (props: StepInitAnalyzeUrlProps) => {\n const { t } = useTranslationRef(catalogImportTranslationRef);\n const {\n onAnalysis,\n analysisUrl = '',\n disablePullRequest = false,\n exampleLocationUrl = 'https://github.com/backstage/backstage/blob/master/catalog-info.yaml',\n } = props;\n\n const errorApi = useApi(errorApiRef);\n const catalogImportApi = useApi(catalogImportApiRef);\n\n const {\n register,\n handleSubmit,\n formState: { errors },\n watch,\n } = useForm<FormData>({\n mode: 'onTouched',\n defaultValues: {\n url: analysisUrl,\n },\n });\n\n const [submitted, setSubmitted] = useState(false);\n const [error, setError] = useState<string | undefined>(undefined);\n\n const handleResult = useCallback(\n async ({ url }: FormData) => {\n setSubmitted(true);\n\n try {\n const analysisResult = await catalogImportApi.analyzeUrl(url);\n\n switch (analysisResult.type) {\n case 'repository':\n if (\n !disablePullRequest &&\n analysisResult.generatedEntities.length > 0\n ) {\n onAnalysis('no-location', url, analysisResult);\n } else {\n setError(t('stepInitAnalyzeUrl.error.repository'));\n setSubmitted(false);\n }\n break;\n\n case 'locations': {\n if (analysisResult.locations.length === 1) {\n onAnalysis('single-location', url, analysisResult, {\n prepareResult: analysisResult,\n });\n } else if (analysisResult.locations.length > 1) {\n onAnalysis('multiple-locations', url, analysisResult);\n } else {\n setError(t('stepInitAnalyzeUrl.error.locations'));\n setSubmitted(false);\n }\n break;\n }\n\n default: {\n const err = t('stepInitAnalyzeUrl.error.default', {\n type: (analysisResult as any).type,\n });\n setError(err);\n setSubmitted(false);\n\n errorApi.post(new Error(err));\n break;\n }\n }\n } catch (e: any) {\n setError(e?.body?.error?.message ?? e.message);\n setSubmitted(false);\n }\n },\n [catalogImportApi, disablePullRequest, errorApi, onAnalysis, t],\n );\n\n return (\n <form onSubmit={handleSubmit(handleResult)}>\n <TextField\n {...asInputRef(\n register('url', {\n required: true,\n validate: {\n httpsValidator: (value: any) =>\n (typeof value === 'string' &&\n value.match(/^http[s]?:\\/\\//) !== null) ||\n t('stepInitAnalyzeUrl.error.url'),\n },\n }),\n )}\n fullWidth\n id=\"url\"\n label=\"URL\"\n placeholder={exampleLocationUrl}\n helperText={t('stepInitAnalyzeUrl.urlHelperText')}\n margin=\"normal\"\n variant=\"outlined\"\n error={Boolean(errors.url)}\n required\n />\n {errors.url && (\n <FormHelperText error>{errors.url.message}</FormHelperText>\n )}\n {error && <FormHelperText error>{error}</FormHelperText>}\n <Grid container spacing={0}>\n <NextButton\n disabled={Boolean(errors.url) || !watch('url')}\n loading={submitted}\n type=\"submit\"\n >\n {t('stepInitAnalyzeUrl.nextButtonText')}\n </NextButton>\n </Grid>\n </form>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA2DO,MAAM,kBAAA,GAAqB,CAAC,KAAA,KAAmC;AACpE,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,2BAA2B,CAAA;AAC3D,EAAA,MAAM;AAAA,IACJ,UAAA;AAAA,IACA,WAAA,GAAc,EAAA;AAAA,IACd,kBAAA,GAAqB,KAAA;AAAA,IACrB,kBAAA,GAAqB;AAAA,GACvB,GAAI,KAAA;AAEJ,EAAA,MAAM,QAAA,GAAW,OAAO,WAAW,CAAA;AACnC,EAAA,MAAM,gBAAA,GAAmB,OAAO,mBAAmB,CAAA;AAEnD,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,YAAA;AAAA,IACA,SAAA,EAAW,EAAE,MAAA,EAAO;AAAA,IACpB;AAAA,MACE,OAAA,CAAkB;AAAA,IACpB,IAAA,EAAM,WAAA;AAAA,IACN,aAAA,EAAe;AAAA,MACb,GAAA,EAAK;AAAA;AACP,GACD,CAAA;AAED,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,SAAS,KAAK,CAAA;AAChD,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAA6B,MAAS,CAAA;AAEhE,EAAA,MAAM,YAAA,GAAe,WAAA;AAAA,IACnB,OAA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AAA,EAAK,MAAE,QAAA,EAAA,KAAA,EAAM,CAAA;AAAA,oBACvC,GAAA,CAAC,IAAA,EAAA,EAAK,SAAA,EAAS,IAAA,EAAC,SAAS,CAAA,EACvB,QAAA,kBAAA,GAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,UAAU,OAAA,CAAQ,MAAA,CAAO,GAAG,CAAA,IAAK,CAAC,MAAM,KAAK,CAAA;AAAA,QAC7C,OAAA,EAAS,SAAA;AAAA,QACT,IAAA,EAAK,QAAA;AAAA,QAEJ,YAAE,mCAAmC;AAAA;AAAA,KACxC,EACF;AAAA,GAAA,EACF,CAAA;AAEJ;;;;"}
@@ -1,5 +1,5 @@
1
1
  var name = "@backstage/plugin-catalog-import";
2
- var version = "0.13.17";
2
+ var version = "0.13.18-next.1";
3
3
  var description = "A Backstage plugin the helps you import entities into your catalog";
4
4
  var backstage = {
5
5
  role: "frontend-plugin",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-import",
3
- "version": "0.13.17",
3
+ "version": "0.13.18-next.1",
4
4
  "description": "A Backstage plugin the helps you import entities into your catalog",
5
5
  "backstage": {
6
6
  "role": "frontend-plugin",
@@ -66,18 +66,18 @@
66
66
  "test": "backstage-cli package test"
67
67
  },
68
68
  "dependencies": {
69
- "@backstage/catalog-client": "^1.16.1",
70
- "@backstage/catalog-model": "^1.10.0",
71
- "@backstage/config": "^1.3.8",
72
- "@backstage/core-components": "^0.18.13",
73
- "@backstage/core-plugin-api": "^1.12.9",
74
- "@backstage/errors": "^1.3.1",
75
- "@backstage/frontend-plugin-api": "^0.18.0",
76
- "@backstage/integration": "^2.1.0",
77
- "@backstage/integration-react": "^1.2.21",
78
- "@backstage/plugin-catalog-common": "^1.1.10",
79
- "@backstage/plugin-catalog-react": "^3.2.2",
80
- "@backstage/plugin-permission-react": "^0.5.4",
69
+ "@backstage/catalog-client": "1.16.2-next.0",
70
+ "@backstage/catalog-model": "1.10.0",
71
+ "@backstage/config": "1.3.8",
72
+ "@backstage/core-components": "0.18.14-next.1",
73
+ "@backstage/core-plugin-api": "1.12.10-next.0",
74
+ "@backstage/errors": "1.3.1",
75
+ "@backstage/frontend-plugin-api": "0.18.1-next.0",
76
+ "@backstage/integration": "2.1.2-next.0",
77
+ "@backstage/integration-react": "1.2.22-next.0",
78
+ "@backstage/plugin-catalog-common": "1.1.10",
79
+ "@backstage/plugin-catalog-react": "3.2.3-next.1",
80
+ "@backstage/plugin-permission-react": "0.5.5-next.0",
81
81
  "@material-ui/core": "^4.12.2",
82
82
  "@material-ui/icons": "^4.9.1",
83
83
  "@material-ui/lab": "4.0.0-alpha.61",
@@ -91,11 +91,11 @@
91
91
  "yaml": "^2.0.0"
92
92
  },
93
93
  "devDependencies": {
94
- "@backstage/cli": "^0.36.5",
95
- "@backstage/core-app-api": "^1.20.4",
96
- "@backstage/dev-utils": "^1.1.26",
97
- "@backstage/plugin-catalog": "^2.0.8",
98
- "@backstage/test-utils": "^1.7.21",
94
+ "@backstage/cli": "0.36.6-next.0",
95
+ "@backstage/core-app-api": "1.20.5-next.1",
96
+ "@backstage/dev-utils": "1.1.27-next.1",
97
+ "@backstage/plugin-catalog": "2.0.9-next.1",
98
+ "@backstage/test-utils": "1.7.22-next.1",
99
99
  "@testing-library/dom": "^10.0.0",
100
100
  "@testing-library/jest-dom": "^6.0.0",
101
101
  "@testing-library/react": "^16.0.0",