@backstage/plugin-catalog-backend-module-gitlab 0.0.0-nightly-20220308022132
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 +14 -0
- package/README.md +8 -0
- package/dist/index.cjs.js +151 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/package.json +56 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @backstage/plugin-catalog-backend-module-gitlab
|
|
2
|
+
|
|
3
|
+
## 0.0.0-nightly-20220308022132
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 66ba5d9023: Added package, moving out gitlab specific functionality from the catalog-backend
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/plugin-catalog-backend@0.0.0-nightly-20220308022132
|
|
13
|
+
- @backstage/backend-common@0.0.0-nightly-20220308022132
|
|
14
|
+
- @backstage/catalog-model@0.0.0-nightly-20220308022132
|
package/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Catalog Backend Module for GitLab
|
|
2
|
+
|
|
3
|
+
This is an extension module to the plugin-catalog-backend plugin, providing extensions targeted at GitLab offerings.
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
See [Backstage documentation](https://backstage.io/docs/integrations/gitlab/discovery) for details on how to install
|
|
8
|
+
and configure the plugin.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var backendCommon = require('@backstage/backend-common');
|
|
6
|
+
var integration = require('@backstage/integration');
|
|
7
|
+
var pluginCatalogBackend = require('@backstage/plugin-catalog-backend');
|
|
8
|
+
var fetch = require('node-fetch');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
|
|
13
|
+
|
|
14
|
+
class GitLabClient {
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.config = options.config;
|
|
17
|
+
this.logger = options.logger;
|
|
18
|
+
}
|
|
19
|
+
isSelfManaged() {
|
|
20
|
+
return this.config.host !== "gitlab.com";
|
|
21
|
+
}
|
|
22
|
+
async listProjects(options) {
|
|
23
|
+
if (options == null ? void 0 : options.group) {
|
|
24
|
+
return this.pagedRequest(`/groups/${encodeURIComponent(options == null ? void 0 : options.group)}/projects`, {
|
|
25
|
+
...options,
|
|
26
|
+
include_subgroups: true
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return this.pagedRequest(`/projects`, options);
|
|
30
|
+
}
|
|
31
|
+
async pagedRequest(endpoint, options) {
|
|
32
|
+
const request = new URL(`${this.config.apiBaseUrl}${endpoint}`);
|
|
33
|
+
for (const key in options) {
|
|
34
|
+
if (options[key]) {
|
|
35
|
+
request.searchParams.append(key, options[key].toString());
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
this.logger.debug(`Fetching: ${request.toString()}`);
|
|
39
|
+
const response = await fetch__default["default"](request.toString(), integration.getGitLabRequestOptions(this.config));
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
throw new Error(`Unexpected response when fetching ${request.toString()}. Expected 200 but got ${response.status} - ${response.statusText}`);
|
|
42
|
+
}
|
|
43
|
+
return response.json().then((items) => {
|
|
44
|
+
const nextPage = response.headers.get("x-next-page");
|
|
45
|
+
return {
|
|
46
|
+
items,
|
|
47
|
+
nextPage: nextPage ? Number(nextPage) : null
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function* paginated(request, options) {
|
|
53
|
+
let res;
|
|
54
|
+
do {
|
|
55
|
+
res = await request(options);
|
|
56
|
+
options.page = res.nextPage;
|
|
57
|
+
for (const item of res.items) {
|
|
58
|
+
yield item;
|
|
59
|
+
}
|
|
60
|
+
} while (res.nextPage);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
class GitLabDiscoveryProcessor {
|
|
64
|
+
static fromConfig(config, options) {
|
|
65
|
+
const integrations = integration.ScmIntegrations.fromConfig(config);
|
|
66
|
+
const pluginCache = backendCommon.CacheManager.fromConfig(config).forPlugin("gitlab-discovery");
|
|
67
|
+
return new GitLabDiscoveryProcessor({
|
|
68
|
+
...options,
|
|
69
|
+
integrations,
|
|
70
|
+
pluginCache
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
constructor(options) {
|
|
74
|
+
this.integrations = options.integrations;
|
|
75
|
+
this.cache = options.pluginCache.getClient();
|
|
76
|
+
this.logger = options.logger;
|
|
77
|
+
}
|
|
78
|
+
getProcessorName() {
|
|
79
|
+
return "GitLabDiscoveryProcessor";
|
|
80
|
+
}
|
|
81
|
+
async readLocation(location, _optional, emit) {
|
|
82
|
+
if (location.type !== "gitlab-discovery") {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
const { group, host, branch, catalogPath } = parseUrl(location.target);
|
|
86
|
+
const integration = this.integrations.gitlab.byUrl(`https://${host}`);
|
|
87
|
+
if (!integration) {
|
|
88
|
+
throw new Error(`There is no GitLab integration that matches ${host}. Please add a configuration entry for it under integrations.gitlab`);
|
|
89
|
+
}
|
|
90
|
+
const client = new GitLabClient({
|
|
91
|
+
config: integration.config,
|
|
92
|
+
logger: this.logger
|
|
93
|
+
});
|
|
94
|
+
const startTimestamp = Date.now();
|
|
95
|
+
this.logger.debug(`Reading GitLab projects from ${location.target}`);
|
|
96
|
+
const projects = paginated((options) => client.listProjects(options), {
|
|
97
|
+
group,
|
|
98
|
+
last_activity_after: await this.updateLastActivity(),
|
|
99
|
+
page: 1
|
|
100
|
+
});
|
|
101
|
+
const res = {
|
|
102
|
+
scanned: 0,
|
|
103
|
+
matches: []
|
|
104
|
+
};
|
|
105
|
+
for await (const project of projects) {
|
|
106
|
+
res.scanned++;
|
|
107
|
+
if (project.archived) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (branch === "*" && project.default_branch === void 0) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
res.matches.push(project);
|
|
114
|
+
}
|
|
115
|
+
for (const project of res.matches) {
|
|
116
|
+
const project_branch = branch === "*" ? project.default_branch : branch;
|
|
117
|
+
emit(pluginCatalogBackend.processingResult.location({
|
|
118
|
+
type: "url",
|
|
119
|
+
target: `${project.web_url}/-/blob/${project_branch}/${catalogPath}`,
|
|
120
|
+
presence: "optional"
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
const duration = ((Date.now() - startTimestamp) / 1e3).toFixed(1);
|
|
124
|
+
this.logger.debug(`Read ${res.scanned} GitLab repositories in ${duration} seconds`);
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
async updateLastActivity() {
|
|
128
|
+
const cacheKey = `processors/${this.getProcessorName()}/last-activity`;
|
|
129
|
+
const lastActivity = await this.cache.get(cacheKey);
|
|
130
|
+
await this.cache.set(cacheKey, new Date().toISOString());
|
|
131
|
+
return lastActivity;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function parseUrl(urlString) {
|
|
135
|
+
const url = new URL(urlString);
|
|
136
|
+
const path = url.pathname.substr(1).split("/");
|
|
137
|
+
const blobIndex = path.findIndex((p) => p === "blob");
|
|
138
|
+
if (blobIndex !== -1 && path.length > blobIndex + 2) {
|
|
139
|
+
const group = blobIndex > 0 ? path.slice(0, blobIndex).join("/") : void 0;
|
|
140
|
+
return {
|
|
141
|
+
group,
|
|
142
|
+
host: url.host,
|
|
143
|
+
branch: decodeURIComponent(path[blobIndex + 1]),
|
|
144
|
+
catalogPath: decodeURIComponent(path.slice(blobIndex + 2).join("/"))
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
throw new Error(`Failed to parse ${urlString}`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
exports.GitLabDiscoveryProcessor = GitLabDiscoveryProcessor;
|
|
151
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/lib/client.ts","../src/GitLabDiscoveryProcessor.ts"],"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 fetch from 'node-fetch';\nimport {\n getGitLabRequestOptions,\n GitLabIntegrationConfig,\n} from '@backstage/integration';\nimport { Logger } from 'winston';\n\nexport type ListOptions = {\n [key: string]: string | number | boolean | undefined;\n group?: string;\n per_page?: number | undefined;\n page?: number | undefined;\n};\n\nexport type PagedResponse<T> = {\n items: T[];\n nextPage?: number;\n};\n\nexport class GitLabClient {\n private readonly config: GitLabIntegrationConfig;\n private readonly logger: Logger;\n\n constructor(options: { config: GitLabIntegrationConfig; logger: Logger }) {\n this.config = options.config;\n this.logger = options.logger;\n }\n\n /**\n * Indicates whether the client is for a SaaS or self managed GitLab instance.\n */\n isSelfManaged(): boolean {\n return this.config.host !== 'gitlab.com';\n }\n\n async listProjects(options?: ListOptions): Promise<PagedResponse<any>> {\n if (options?.group) {\n return this.pagedRequest(\n `/groups/${encodeURIComponent(options?.group)}/projects`,\n {\n ...options,\n include_subgroups: true,\n },\n );\n }\n\n return this.pagedRequest(`/projects`, options);\n }\n\n /**\n * Performs a request against a given paginated GitLab endpoint.\n *\n * This method may be used to perform authenticated REST calls against any\n * paginated GitLab endpoint which uses X-NEXT-PAGE headers. The return value\n * can be be used with the {@link paginated} async-generator function to yield\n * each item from the paged request.\n *\n * @see {@link paginated}\n * @param endpoint - The request endpoint, e.g. /projects.\n * @param options - Request queryString options which may also include page variables.\n */\n async pagedRequest<T = any>(\n endpoint: string,\n options?: ListOptions,\n ): Promise<PagedResponse<T>> {\n const request = new URL(`${this.config.apiBaseUrl}${endpoint}`);\n for (const key in options) {\n if (options[key]) {\n request.searchParams.append(key, options[key]!.toString());\n }\n }\n\n this.logger.debug(`Fetching: ${request.toString()}`);\n const response = await fetch(\n request.toString(),\n getGitLabRequestOptions(this.config),\n );\n if (!response.ok) {\n throw new Error(\n `Unexpected response when fetching ${request.toString()}. Expected 200 but got ${\n response.status\n } - ${response.statusText}`,\n );\n }\n return response.json().then(items => {\n const nextPage = response.headers.get('x-next-page');\n\n return {\n items,\n nextPage: nextPage ? Number(nextPage) : null,\n } as PagedResponse<any>;\n });\n }\n}\n\n/**\n * Advances through each page and provides each item from a paginated request.\n *\n * The async generator function yields each item from repeated calls to the\n * provided request function. The generator walks through each available page by\n * setting the page key in the options passed into the request function and\n * making repeated calls until there are no more pages.\n *\n * @see {@link pagedRequest}\n * @param request - Function which returns a PagedResponse to walk through.\n * @param options - Initial ListOptions for the request function.\n */\nexport async function* paginated<T = any>(\n request: (options: ListOptions) => Promise<PagedResponse<T>>,\n options: ListOptions,\n) {\n let res;\n do {\n res = await request(options);\n options.page = res.nextPage;\n for (const item of res.items) {\n yield item;\n }\n } while (res.nextPage);\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n CacheClient,\n CacheManager,\n PluginCacheManager,\n} from '@backstage/backend-common';\nimport { Config } from '@backstage/config';\nimport {\n ScmIntegrationRegistry,\n ScmIntegrations,\n} from '@backstage/integration';\nimport {\n CatalogProcessor,\n CatalogProcessorEmit,\n LocationSpec,\n processingResult,\n} from '@backstage/plugin-catalog-backend';\nimport { Logger } from 'winston';\nimport { GitLabClient, GitLabProject, paginated } from './lib';\n\n/**\n * Extracts repositories out of an GitLab instance.\n * @public\n */\nexport class GitLabDiscoveryProcessor implements CatalogProcessor {\n private readonly integrations: ScmIntegrationRegistry;\n private readonly logger: Logger;\n private readonly cache: CacheClient;\n\n static fromConfig(config: Config, options: { logger: Logger }) {\n const integrations = ScmIntegrations.fromConfig(config);\n const pluginCache =\n CacheManager.fromConfig(config).forPlugin('gitlab-discovery');\n\n return new GitLabDiscoveryProcessor({\n ...options,\n integrations,\n pluginCache,\n });\n }\n\n private constructor(options: {\n integrations: ScmIntegrationRegistry;\n pluginCache: PluginCacheManager;\n logger: Logger;\n }) {\n this.integrations = options.integrations;\n this.cache = options.pluginCache.getClient();\n this.logger = options.logger;\n }\n\n getProcessorName(): string {\n return 'GitLabDiscoveryProcessor';\n }\n\n async readLocation(\n location: LocationSpec,\n _optional: boolean,\n emit: CatalogProcessorEmit,\n ): Promise<boolean> {\n if (location.type !== 'gitlab-discovery') {\n return false;\n }\n\n const { group, host, branch, catalogPath } = parseUrl(location.target);\n\n const integration = this.integrations.gitlab.byUrl(`https://${host}`);\n if (!integration) {\n throw new Error(\n `There is no GitLab integration that matches ${host}. Please add a configuration entry for it under integrations.gitlab`,\n );\n }\n\n const client = new GitLabClient({\n config: integration.config,\n logger: this.logger,\n });\n const startTimestamp = Date.now();\n this.logger.debug(`Reading GitLab projects from ${location.target}`);\n\n const projects = paginated(options => client.listProjects(options), {\n group,\n last_activity_after: await this.updateLastActivity(),\n page: 1,\n });\n\n const res: Result = {\n scanned: 0,\n matches: [],\n };\n for await (const project of projects) {\n res.scanned++;\n\n if (project.archived) {\n continue;\n }\n\n if (branch === '*' && project.default_branch === undefined) {\n continue;\n }\n\n res.matches.push(project);\n }\n\n for (const project of res.matches) {\n const project_branch = branch === '*' ? project.default_branch : branch;\n\n emit(\n processingResult.location({\n type: 'url',\n // The format expected by the GitLabUrlReader:\n // https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath\n //\n // This unfortunately will trigger another API call in `getGitLabFileFetchUrl` to get the project ID.\n // The alternative is using the `buildRawUrl` function, which does not support subgroups, so providing a raw\n // URL here won't work either.\n target: `${project.web_url}/-/blob/${project_branch}/${catalogPath}`,\n presence: 'optional',\n }),\n );\n }\n\n const duration = ((Date.now() - startTimestamp) / 1000).toFixed(1);\n this.logger.debug(\n `Read ${res.scanned} GitLab repositories in ${duration} seconds`,\n );\n\n return true;\n }\n\n private async updateLastActivity(): Promise<string | undefined> {\n const cacheKey = `processors/${this.getProcessorName()}/last-activity`;\n const lastActivity = await this.cache.get(cacheKey);\n await this.cache.set(cacheKey, new Date().toISOString());\n return lastActivity as string | undefined;\n }\n}\n\ntype Result = {\n scanned: number;\n matches: GitLabProject[];\n};\n\n/*\n * Helpers\n */\n\nexport function parseUrl(urlString: string): {\n group?: string;\n host: string;\n branch: string;\n catalogPath: string;\n} {\n const url = new URL(urlString);\n const path = url.pathname.substr(1).split('/');\n\n // (/group/subgroup)/blob/branch|*/filepath\n const blobIndex = path.findIndex(p => p === 'blob');\n if (blobIndex !== -1 && path.length > blobIndex + 2) {\n const group =\n blobIndex > 0 ? path.slice(0, blobIndex).join('/') : undefined;\n\n return {\n group,\n host: url.host,\n branch: decodeURIComponent(path[blobIndex + 1]),\n catalogPath: decodeURIComponent(path.slice(blobIndex + 2).join('/')),\n };\n }\n\n throw new Error(`Failed to parse ${urlString}`);\n}\n"],"names":["fetch","getGitLabRequestOptions","ScmIntegrations","CacheManager","processingResult"],"mappings":";;;;;;;;;;;;;mBAmC0B;AAAA,EAIxB,YAAY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AC9D,UAAM,WAAW,cAAc,KAAK;AACpC,UAAM,eAAe,MAAM,KAAK,MAAM,IAAI;AAC1C,UAAM,KAAK,MAAM,IAAI,UAAU,IAAI,OAAO;AAC1C,WAAO;AAAA;AAAA;kBAac,WAKvB;AACA,QAAM,MAAM,IAAI,IAAI;AACpB,QAAM,OAAO,IAAI,SAAS,OAAO,GAAG,MAAM;AAG1C,QAAM,YAAY,KAAK,UAAU,OAAK,MAAM;AAC5C,MAAI,cAAc,MAAM,KAAK,SAAS,YAAY,GAAG;AACnD,UAAM,QACJ,YAAY,IAAI,KAAK,MAAM,GAAG,WAAW,KAAK,OAAO;AAEvD,WAAO;AAAA,MACL;AAAA,MACA,MAAM,IAAI;AAAA,MACV,QAAQ,mBAAmB,KAAK,YAAY;AAAA,MAC5C,aAAa,mBAAmB,KAAK,MAAM,YAAY,GAAG,KAAK;AAAA;AAAA;AAInE,QAAM,IAAI,MAAM,mBAAmB;AAAA;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Config } from '@backstage/config';
|
|
2
|
+
import { CatalogProcessor, LocationSpec, CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
|
|
3
|
+
import { Logger } from 'winston';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Extracts repositories out of an GitLab instance.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
declare class GitLabDiscoveryProcessor implements CatalogProcessor {
|
|
10
|
+
private readonly integrations;
|
|
11
|
+
private readonly logger;
|
|
12
|
+
private readonly cache;
|
|
13
|
+
static fromConfig(config: Config, options: {
|
|
14
|
+
logger: Logger;
|
|
15
|
+
}): GitLabDiscoveryProcessor;
|
|
16
|
+
private constructor();
|
|
17
|
+
getProcessorName(): string;
|
|
18
|
+
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
19
|
+
private updateLastActivity;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { GitLabDiscoveryProcessor };
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@backstage/plugin-catalog-backend-module-gitlab",
|
|
3
|
+
"description": "A Backstage catalog backend module that helps integrate towards GitLab",
|
|
4
|
+
"version": "0.0.0-nightly-20220308022132",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"private": false,
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public",
|
|
11
|
+
"main": "dist/index.cjs.js",
|
|
12
|
+
"types": "dist/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"backstage": {
|
|
15
|
+
"role": "backend-plugin-module"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://backstage.io",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/backstage/backstage",
|
|
21
|
+
"directory": "plugins/catalog-backend-module-gitlab"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"backstage"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "backstage-cli package build",
|
|
28
|
+
"lint": "backstage-cli package lint",
|
|
29
|
+
"test": "backstage-cli package test",
|
|
30
|
+
"prepack": "backstage-cli package prepack",
|
|
31
|
+
"postpack": "backstage-cli package postpack",
|
|
32
|
+
"clean": "backstage-cli package clean",
|
|
33
|
+
"start": "backstage-cli package start"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@backstage/backend-common": "^0.0.0-nightly-20220308022132",
|
|
37
|
+
"@backstage/catalog-model": "^0.0.0-nightly-20220308022132",
|
|
38
|
+
"@backstage/config": "^0.1.15",
|
|
39
|
+
"@backstage/errors": "^0.2.2",
|
|
40
|
+
"@backstage/integration": "^0.8.0",
|
|
41
|
+
"@backstage/plugin-catalog-backend": "^0.0.0-nightly-20220308022132",
|
|
42
|
+
"@backstage/types": "^0.1.3",
|
|
43
|
+
"lodash": "^4.17.21",
|
|
44
|
+
"msw": "^0.35.0",
|
|
45
|
+
"node-fetch": "^2.6.7",
|
|
46
|
+
"winston": "^3.2.1"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@backstage/backend-test-utils": "^0.0.0-nightly-20220308022132",
|
|
50
|
+
"@backstage/cli": "^0.0.0-nightly-20220308022132",
|
|
51
|
+
"@types/lodash": "^4.14.151"
|
|
52
|
+
},
|
|
53
|
+
"files": [
|
|
54
|
+
"dist"
|
|
55
|
+
]
|
|
56
|
+
}
|