@backstage/plugin-scaffolder-backend-module-gitlab 0.1.1-next.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-gitlab
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 439e2986be1: Add a new scaffolder action for gitlab to ensure a group exists
8
+
9
+ ### Patch Changes
10
+
11
+ - f1496d4ab6f: Fix input schema validation issue for gitlab actions:
12
+
13
+ - gitlab:group:ensureExists
14
+ - gitlab:projectAccessToken:create
15
+ - gitlab:projectDeployToken:create
16
+ - gitlab:projectVariable:create
17
+
18
+ - Updated dependencies
19
+ - @backstage/integration@1.4.5
20
+ - @backstage/plugin-scaffolder-node@0.1.3
21
+ - @backstage/config@1.0.7
22
+ - @backstage/errors@1.1.5
23
+
24
+ ## 0.2.0-next.2
25
+
26
+ ### Minor Changes
27
+
28
+ - 439e2986be1: Add a new scaffolder action for gitlab to ensure a group exists
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies
33
+ - @backstage/plugin-scaffolder-node@0.1.3-next.2
34
+ - @backstage/config@1.0.7
35
+
3
36
  ## 0.1.1-next.1
4
37
 
5
38
  ### Patch Changes
package/README.md CHANGED
@@ -45,6 +45,9 @@ const actions = [
45
45
  createGitlabProjectDeployTokenAction({
46
46
  integrations: integrations,
47
47
  }),
48
+ createGitlabGroupEnsureExistsAction({
49
+ integrations: integrations,
50
+ }),
48
51
  ];
49
52
 
50
53
  // Create Scaffolder Router
@@ -104,13 +107,22 @@ spec:
104
107
  url: https://github.com/TEMPLATE
105
108
  values:
106
109
  name: ${{ parameters.name }}
110
+ - id: createGitlabGroup
111
+ name: Ensure Gitlab group exists
112
+ action: gitlab:group:ensureExists
113
+ input:
114
+ repoUrl: ${{ parameters.repoUrl }}
115
+ path:
116
+ - path
117
+ - to
118
+ - group
107
119
 
108
120
  - id: publish
109
121
  name: Publish
110
122
  action: publish:gitlab
111
123
  input:
112
124
  description: This is ${{ parameters.name }}
113
- repoUrl: ${{ parameters.repoUrl }}
125
+ repoUrl: ${{ parameters.repoUrl }}?owner=${{ steps.createGitlabGroup.output.groupId }}
114
126
  sourcePath: pimcore
115
127
  defaultBranch: main
116
128
 
package/dist/index.cjs.js CHANGED
@@ -4,8 +4,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
6
6
  var node = require('@gitbeaker/node');
7
+ var zod = require('zod');
7
8
  var errors = require('@backstage/errors');
8
9
 
10
+ const commonGitlabConfig = zod.z.object({
11
+ repoUrl: zod.z.string({ description: "Repository Location" }),
12
+ token: zod.z.string({ description: "The token to use for authorization to GitLab" }).optional()
13
+ });
14
+
9
15
  const parseRepoHost = (repoUrl) => {
10
16
  let parsed;
11
17
  try {
@@ -17,80 +23,101 @@ const parseRepoHost = (repoUrl) => {
17
23
  }
18
24
  return parsed.host;
19
25
  };
20
- const getToken = (repoUrl, inputToken, integrations) => {
21
- const host = parseRepoHost(repoUrl);
26
+ const getToken = (config, integrations) => {
27
+ const host = parseRepoHost(config.repoUrl);
22
28
  const integrationConfig = integrations.gitlab.byHost(host);
23
29
  if (!integrationConfig) {
24
30
  throw new errors.InputError(
25
31
  `No matching integration configuration for host ${host}, please check your integrations config`
26
32
  );
27
33
  }
28
- const token = inputToken || integrationConfig.config.token;
29
- const tokenType = inputToken ? "oauthToken" : "token";
34
+ const token = config.token || integrationConfig.config.token;
35
+ const tokenType = config.token ? "oauthToken" : "token";
30
36
  if (tokenType === "oauthToken") {
31
37
  throw new errors.InputError(`OAuth Token is currently not supported`);
32
38
  }
33
39
  return { token, integrationConfig };
34
40
  };
35
41
 
36
- const createGitlabProjectDeployTokenAction = (options) => {
42
+ const createGitlabGroupEnsureExistsAction = (options) => {
37
43
  const { integrations } = options;
38
44
  return pluginScaffolderNode.createTemplateAction({
39
- id: "gitlab:projectDeployToken:create",
45
+ id: "gitlab:group:ensureExists",
46
+ description: "Ensures a Gitlab group exists",
40
47
  schema: {
41
- input: {
42
- required: ["projectId", "repoUrl"],
43
- type: "object",
44
- properties: {
45
- repoUrl: {
46
- title: "Repository Location",
47
- type: "string"
48
- },
49
- projectId: {
50
- title: "Project ID",
51
- type: ["string", "number"]
52
- },
53
- name: {
54
- title: "Deploy Token Name",
55
- type: "string"
56
- },
57
- username: {
58
- title: "Deploy Token Username",
59
- type: "string"
60
- },
61
- scopes: {
62
- title: "Scopes",
63
- type: "array"
64
- },
65
- token: {
66
- title: "Authentication Token",
67
- type: "string",
68
- description: "The token to use for authorization to GitLab"
69
- }
70
- }
71
- },
72
- output: {
73
- type: "object",
74
- properties: {
75
- deploy_token: {
76
- title: "Deploy Token",
77
- type: "string"
78
- },
79
- user: {
80
- title: "User",
81
- type: "string"
82
- }
48
+ input: commonGitlabConfig.merge(
49
+ zod.z.object({
50
+ path: zod.z.array(zod.z.string(), {
51
+ description: "A path of group names that is ensured to exist"
52
+ }).min(1)
53
+ })
54
+ ),
55
+ output: zod.z.object({
56
+ groupId: zod.z.number({ description: "The id of the innermost sub-group" }).optional()
57
+ })
58
+ },
59
+ async handler(ctx) {
60
+ const { path } = ctx.input;
61
+ const { token, integrationConfig } = getToken(ctx.input, integrations);
62
+ const api = new node.Gitlab({
63
+ host: integrationConfig.config.baseUrl,
64
+ token
65
+ });
66
+ let currentPath = "repos";
67
+ let parent = null;
68
+ for (const pathElement of path) {
69
+ const fullPath = `${currentPath}/${pathElement}`;
70
+ const result = await api.Groups.search(
71
+ fullPath
72
+ );
73
+ const subGroup = result.find(
74
+ (searchPathElem) => searchPathElem.full_path === fullPath
75
+ );
76
+ if (!subGroup) {
77
+ ctx.logger.info(`creating missing group ${fullPath}`);
78
+ parent = await api.Groups.create(
79
+ pathElement,
80
+ pathElement,
81
+ parent ? {
82
+ parent_id: parent.id
83
+ } : {}
84
+ );
85
+ } else {
86
+ parent = subGroup;
83
87
  }
88
+ currentPath = fullPath;
84
89
  }
90
+ if (parent !== null) {
91
+ ctx.output("groupId", parent == null ? void 0 : parent.id);
92
+ }
93
+ }
94
+ });
95
+ };
96
+
97
+ const createGitlabProjectDeployTokenAction = (options) => {
98
+ const { integrations } = options;
99
+ return pluginScaffolderNode.createTemplateAction({
100
+ id: "gitlab:projectDeployToken:create",
101
+ schema: {
102
+ input: commonGitlabConfig.merge(
103
+ zod.z.object({
104
+ projectId: zod.z.union([zod.z.number(), zod.z.string()], {
105
+ description: "Project ID"
106
+ }),
107
+ name: zod.z.string({ description: "Deploy Token Name" }),
108
+ username: zod.z.string({ description: "Deploy Token Username" }).optional(),
109
+ scopes: zod.z.array(zod.z.string(), { description: "Scopes" }).optional()
110
+ })
111
+ ),
112
+ output: zod.z.object({
113
+ deploy_token: zod.z.string({ description: "Deploy Token" }),
114
+ user: zod.z.string({ description: "User" })
115
+ })
85
116
  },
86
117
  async handler(ctx) {
87
118
  ctx.logger.info(`Creating Token for Project "${ctx.input.projectId}"`);
88
- const { repoUrl, projectId, name, username, scopes } = ctx.input;
89
- const { token, integrationConfig } = getToken(
90
- repoUrl,
91
- ctx.input.token,
92
- integrations
93
- );
119
+ const { projectId, name, username, scopes } = ctx.input;
120
+ const { token, integrationConfig } = getToken(ctx.input, integrations);
94
121
  const api = new node.Gitlab({
95
122
  host: integrationConfig.config.baseUrl,
96
123
  token
@@ -117,55 +144,24 @@ const createGitlabProjectAccessTokenAction = (options) => {
117
144
  return pluginScaffolderNode.createTemplateAction({
118
145
  id: "gitlab:projectAccessToken:create",
119
146
  schema: {
120
- input: {
121
- required: ["projectId", "repoUrl"],
122
- type: "object",
123
- properties: {
124
- repoUrl: {
125
- title: "Repository Location",
126
- type: "string"
127
- },
128
- projectId: {
129
- title: "Project ID",
130
- type: ["string", "number"]
131
- },
132
- name: {
133
- title: "Deploy Token Name",
134
- type: "string"
135
- },
136
- accessLevel: {
137
- title: "Access Level of the Token",
138
- type: "number"
139
- },
140
- scopes: {
141
- title: "Scopes",
142
- type: "array"
143
- },
144
- token: {
145
- title: "Authentication Token",
146
- type: "string",
147
- description: "The token to use for authorization to GitLab"
148
- }
149
- }
150
- },
151
- output: {
152
- type: "object",
153
- properties: {
154
- access_token: {
155
- title: "Access Token",
156
- type: "string"
157
- }
158
- }
159
- }
147
+ input: commonGitlabConfig.merge(
148
+ zod.z.object({
149
+ projectId: zod.z.union([zod.z.number(), zod.z.string()], {
150
+ description: "Project ID"
151
+ }),
152
+ name: zod.z.string({ description: "Deploy Token Name" }).optional(),
153
+ accessLevel: zod.z.number({ description: "Access Level of the Token" }).optional(),
154
+ scopes: zod.z.array(zod.z.string(), { description: "Scopes" }).optional()
155
+ })
156
+ ),
157
+ output: zod.z.object({
158
+ access_token: zod.z.string({ description: "Access Token" })
159
+ })
160
160
  },
161
161
  async handler(ctx) {
162
162
  ctx.logger.info(`Creating Token for Project "${ctx.input.projectId}"`);
163
- const { repoUrl, projectId, name, accessLevel, scopes } = ctx.input;
164
- const { token, integrationConfig } = getToken(
165
- repoUrl,
166
- ctx.input.token,
167
- integrations
168
- );
163
+ const { projectId, name, accessLevel, scopes } = ctx.input;
164
+ const { token, integrationConfig } = getToken(ctx.input, integrations);
169
165
  const response = await fetch(
170
166
  `${integrationConfig.config.baseUrl}/api/v4/projects/${projectId}/access_tokens`,
171
167
  {
@@ -193,81 +189,37 @@ const createGitlabProjectVariableAction = (options) => {
193
189
  return pluginScaffolderNode.createTemplateAction({
194
190
  id: "gitlab:projectVariable:create",
195
191
  schema: {
196
- input: {
197
- required: [
198
- "repoUrl",
199
- "projectId",
200
- "key",
201
- "value",
202
- "variableType",
203
- "variableProtected",
204
- "masked",
205
- "raw",
206
- "environmentScope"
207
- ],
208
- type: "object",
209
- properties: {
210
- repoUrl: {
211
- title: "Repository Location",
212
- type: "string"
213
- },
214
- projectId: {
215
- title: "Project ID",
216
- type: ["string", "number"]
217
- },
218
- key: {
219
- title: "The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed",
220
- type: "string"
221
- },
222
- value: {
223
- title: "The value of a variable",
224
- type: "string"
225
- },
226
- variableType: {
227
- title: "Variable Type (env_var or file)",
228
- type: "string"
229
- },
230
- variableProtected: {
231
- title: "Whether the variable is protected. Default: false",
232
- type: "boolean"
233
- },
234
- masked: {
235
- title: "Whether the variable is masked. Default: false",
236
- type: "boolean"
237
- },
238
- raw: {
239
- title: "Whether the variable is expandable. Default: false",
240
- type: "boolean"
241
- },
242
- environmentScope: {
243
- title: "The environment_scope of the variable. Default: *",
244
- type: "string"
245
- },
246
- token: {
247
- title: "Authentication Token",
248
- type: "string",
249
- description: "The token to use for authorization to GitLab"
250
- }
251
- }
252
- }
192
+ input: commonGitlabConfig.merge(
193
+ zod.z.object({
194
+ projectId: zod.z.union([zod.z.number(), zod.z.string()], {
195
+ description: "Project ID"
196
+ }),
197
+ key: zod.z.string({
198
+ description: "The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed"
199
+ }).regex(/^[A-Za-z0-9_]{1,255}$/),
200
+ value: zod.z.string({ description: "The value of a variable" }),
201
+ variableType: zod.z.string({
202
+ description: "Variable Type (env_var or file)"
203
+ }),
204
+ variableProtected: zod.z.boolean({ description: "Whether the variable is protected" }).default(false).optional(),
205
+ masked: zod.z.boolean({ description: "Whether the variable is masked" }).default(false).optional(),
206
+ raw: zod.z.boolean({ description: "Whether the variable is expandable" }).default(false).optional(),
207
+ environmentScope: zod.z.string({ description: "The environment_scope of the variable" }).default("*").optional()
208
+ })
209
+ )
253
210
  },
254
211
  async handler(ctx) {
255
212
  const {
256
- repoUrl,
257
213
  projectId,
258
214
  key,
259
215
  value,
260
216
  variableType,
261
- variableProtected,
262
- masked,
263
- raw,
264
- environmentScope
217
+ variableProtected = false,
218
+ masked = false,
219
+ raw = false,
220
+ environmentScope = "*"
265
221
  } = ctx.input;
266
- const { token, integrationConfig } = getToken(
267
- repoUrl,
268
- ctx.input.token,
269
- integrations
270
- );
222
+ const { token, integrationConfig } = getToken(ctx.input, integrations);
271
223
  const api = new node.Gitlab({
272
224
  host: integrationConfig.config.baseUrl,
273
225
  token
@@ -285,6 +237,7 @@ const createGitlabProjectVariableAction = (options) => {
285
237
  });
286
238
  };
287
239
 
240
+ exports.createGitlabGroupEnsureExistsAction = createGitlabGroupEnsureExistsAction;
288
241
  exports.createGitlabProjectAccessTokenAction = createGitlabProjectAccessTokenAction;
289
242
  exports.createGitlabProjectDeployTokenAction = createGitlabProjectDeployTokenAction;
290
243
  exports.createGitlabProjectVariableAction = createGitlabProjectVariableAction;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/util.ts","../src/actions/createGitlabProjectDeployTokenAction.ts","../src/actions/createGitlabProjectAccessTokenAction.ts","../src/actions/createGitlabProjectVariableAction.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 { InputError } from '@backstage/errors';\nimport {\n GitLabIntegration,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\n\nexport const parseRepoHost = (repoUrl: string): string => {\n let parsed;\n try {\n parsed = new URL(`https://${repoUrl}`);\n } catch (error) {\n throw new InputError(\n `Invalid repo URL passed to publisher, got ${repoUrl}, ${error}`,\n );\n }\n return parsed.host;\n};\n\nexport const getToken = (\n repoUrl: string,\n inputToken: string | null | undefined,\n integrations: ScmIntegrationRegistry,\n): { token: string; integrationConfig: GitLabIntegration } => {\n const host = parseRepoHost(repoUrl);\n const integrationConfig = integrations.gitlab.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n const token = inputToken || integrationConfig.config.token!;\n const tokenType = inputToken ? 'oauthToken' : 'token';\n\n if (tokenType === 'oauthToken') {\n throw new InputError(`OAuth Token is currently not supported`);\n }\n\n return { token: token, integrationConfig: integrationConfig };\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { Gitlab } from '@gitbeaker/node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { DeployTokenScope } from '@gitbeaker/core/dist/types/templates/ResourceDeployTokens';\nimport { getToken } from '../util';\nimport { InputError } from '@backstage/errors';\n\n/**\n * Creates a `gitlab:create-project-deploy-token` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectDeployTokenAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction<{\n repoUrl: string;\n projectId: string | number;\n name: string;\n username: string;\n scopes: string[];\n token?: string;\n }>({\n id: 'gitlab:projectDeployToken:create',\n schema: {\n input: {\n required: ['projectId', 'repoUrl'],\n type: 'object',\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n projectId: {\n title: 'Project ID',\n type: ['string', 'number'],\n },\n name: {\n title: 'Deploy Token Name',\n type: 'string',\n },\n username: {\n title: 'Deploy Token Username',\n type: 'string',\n },\n scopes: {\n title: 'Scopes',\n type: 'array',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitLab',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n deploy_token: {\n title: 'Deploy Token',\n type: 'string',\n },\n user: {\n title: 'User',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n ctx.logger.info(`Creating Token for Project \"${ctx.input.projectId}\"`);\n const { repoUrl, projectId, name, username, scopes } = ctx.input;\n const { token, integrationConfig } = getToken(\n repoUrl,\n ctx.input.token,\n integrations,\n );\n\n const api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n\n const deployToken = await api.ProjectDeployTokens.add(\n projectId,\n name,\n scopes as DeployTokenScope[],\n {\n username: username,\n },\n );\n\n if (!deployToken.hasOwnProperty('token')) {\n throw new InputError(`No deploy_token given from gitlab instance`);\n }\n\n ctx.output('deploy_token', deployToken.token as string);\n ctx.output('user', deployToken.username);\n },\n });\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getToken } from '../util';\n\n/**\n * Creates a `gitlab:create-project-access-token` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectAccessTokenAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction<{\n repoUrl: string;\n projectId: string | number;\n name: string;\n accessLevel: number;\n scopes: string[];\n token?: string;\n }>({\n id: 'gitlab:projectAccessToken:create',\n schema: {\n input: {\n required: ['projectId', 'repoUrl'],\n type: 'object',\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n projectId: {\n title: 'Project ID',\n type: ['string', 'number'],\n },\n name: {\n title: 'Deploy Token Name',\n type: 'string',\n },\n accessLevel: {\n title: 'Access Level of the Token',\n type: 'number',\n },\n scopes: {\n title: 'Scopes',\n type: 'array',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitLab',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n access_token: {\n title: 'Access Token',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n ctx.logger.info(`Creating Token for Project \"${ctx.input.projectId}\"`);\n const { repoUrl, projectId, name, accessLevel, scopes } = ctx.input;\n const { token, integrationConfig } = getToken(\n repoUrl,\n ctx.input.token,\n integrations,\n );\n\n const response = await fetch(\n `${integrationConfig.config.baseUrl}/api/v4/projects/${projectId}/access_tokens`,\n {\n method: 'POST', // *GET, POST, PUT, DELETE, etc.\n headers: {\n 'PRIVATE-TOKEN': token,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n name: name,\n scopes: scopes,\n access_level: accessLevel,\n }),\n },\n );\n\n const result = await response.json();\n\n ctx.output('access_token', result.token);\n },\n });\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getToken } from '../util';\nimport { Gitlab } from '@gitbeaker/node';\n\n/**\n * Creates a `gitlab:create-project-variable` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectVariableAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction<{\n repoUrl: string;\n projectId: string | number;\n key: string;\n value: string;\n variableType: string;\n variableProtected: boolean;\n masked: boolean;\n raw: boolean;\n environmentScope: string;\n token?: string;\n }>({\n id: 'gitlab:projectVariable:create',\n schema: {\n input: {\n required: [\n 'repoUrl',\n 'projectId',\n 'key',\n 'value',\n 'variableType',\n 'variableProtected',\n 'masked',\n 'raw',\n 'environmentScope',\n ],\n type: 'object',\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n projectId: {\n title: 'Project ID',\n type: ['string', 'number'],\n },\n key: {\n title:\n 'The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed',\n type: 'string',\n },\n value: {\n title: 'The value of a variable',\n type: 'string',\n },\n variableType: {\n title: 'Variable Type (env_var or file)',\n type: 'string',\n },\n variableProtected: {\n title: 'Whether the variable is protected. Default: false',\n type: 'boolean',\n },\n masked: {\n title: 'Whether the variable is masked. Default: false',\n type: 'boolean',\n },\n raw: {\n title: 'Whether the variable is expandable. Default: false',\n type: 'boolean',\n },\n environmentScope: {\n title: 'The environment_scope of the variable. Default: *',\n type: 'string',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitLab',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n projectId,\n key,\n value,\n variableType,\n variableProtected,\n masked,\n raw,\n environmentScope,\n } = ctx.input;\n const { token, integrationConfig } = getToken(\n repoUrl,\n ctx.input.token,\n integrations,\n );\n\n const api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n\n await api.ProjectVariables.create(projectId, {\n key: key,\n value: value,\n variable_type: variableType,\n protected: variableProtected,\n masked: masked,\n raw: raw,\n environment_scope: environmentScope,\n });\n },\n });\n};\n"],"names":["InputError","createTemplateAction","Gitlab"],"mappings":";;;;;;;;AAsBa,MAAA,aAAA,GAAgB,CAAC,OAA4B,KAAA;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A;AAEA,MAAM,MAAA,GAAA,GAAM,IAAIC,WAAO,CAAA;AAAA,QACrB,IAAA,EAAM,kBAAkB,MAAO,CAAA,OAAA;AAAA,QAC/B,KAAA;AAAA,OACD,CAAA,CAAA;AAED,MAAM,MAAA,GAAA,CAAI,gBAAiB,CAAA,MAAA,CAAO,SAAW,EAAA;AAAA,QAC3C,GAAA;AAAA,QACA,KAAA;AAAA,QACA,aAAe,EAAA,YAAA;AAAA,QACf,SAAW,EAAA,iBAAA;AAAA,QACX,MAAA;AAAA,QACA,GAAA;AAAA,QACA,iBAAmB,EAAA,gBAAA;AAAA,OACpB,CAAA,CAAA;AAAA,KACH;AAAA,GACD,CAAA,CAAA;AACH;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/commonGitlabConfig.ts","../src/util.ts","../src/actions/createGitlabGroupEnsureExistsAction.ts","../src/actions/createGitlabProjectDeployTokenAction.ts","../src/actions/createGitlabProjectAccessTokenAction.ts","../src/actions/createGitlabProjectVariableAction.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 { z } from 'zod';\n\nconst commonGitlabConfig = z.object({\n repoUrl: z.string({ description: 'Repository Location' }),\n token: z\n .string({ description: 'The token to use for authorization to GitLab' })\n .optional(),\n});\n\nexport default commonGitlabConfig;\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 { InputError } from '@backstage/errors';\nimport {\n GitLabIntegration,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { z } from 'zod';\nimport commonGitlabConfig from './commonGitlabConfig';\n\nexport const parseRepoHost = (repoUrl: string): string => {\n let parsed;\n try {\n parsed = new URL(`https://${repoUrl}`);\n } catch (error) {\n throw new InputError(\n `Invalid repo URL passed to publisher, got ${repoUrl}, ${error}`,\n );\n }\n return parsed.host;\n};\n\nexport const getToken = (\n config: z.infer<typeof commonGitlabConfig>,\n integrations: ScmIntegrationRegistry,\n): { token: string; integrationConfig: GitLabIntegration } => {\n const host = parseRepoHost(config.repoUrl);\n const integrationConfig = integrations.gitlab.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n const token = config.token || integrationConfig.config.token!;\n const tokenType = config.token ? 'oauthToken' : 'token';\n\n if (tokenType === 'oauthToken') {\n throw new InputError(`OAuth Token is currently not supported`);\n }\n\n return { token: token, integrationConfig: integrationConfig };\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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { Gitlab } from '@gitbeaker/node';\nimport { GroupSchema } from '@gitbeaker/core/dist/types/resources/Groups';\nimport commonGitlabConfig from '../commonGitlabConfig';\nimport { getToken } from '../util';\nimport { z } from 'zod';\n\n/**\n * Creates an `gitlab:group:ensureExists` Scaffolder action.\n *\n * @public\n */\nexport const createGitlabGroupEnsureExistsAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction({\n id: 'gitlab:group:ensureExists',\n description: 'Ensures a Gitlab group exists',\n schema: {\n input: commonGitlabConfig.merge(\n z.object({\n path: z\n .array(z.string(), {\n description: 'A path of group names that is ensured to exist',\n })\n .min(1),\n }),\n ),\n output: z.object({\n groupId: z\n .number({ description: 'The id of the innermost sub-group' })\n .optional(),\n }),\n },\n async handler(ctx) {\n const { path } = ctx.input;\n const { token, integrationConfig } = getToken(ctx.input, integrations);\n\n const api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n\n let currentPath: string = 'repos';\n let parent: GroupSchema | null = null;\n for (const pathElement of path) {\n const fullPath = `${currentPath}/${pathElement}`;\n const result = (await api.Groups.search(\n fullPath,\n )) as any as Array<GroupSchema>; // recast since the return type for search is wrong in the gitbeaker typings\n const subGroup = result.find(\n searchPathElem => searchPathElem.full_path === fullPath,\n );\n if (!subGroup) {\n ctx.logger.info(`creating missing group ${fullPath}`);\n parent = await api.Groups.create(\n pathElement,\n pathElement,\n parent\n ? {\n parent_id: parent.id,\n }\n : {},\n );\n } else {\n parent = subGroup;\n }\n currentPath = fullPath;\n }\n if (parent !== null) {\n ctx.output('groupId', parent?.id);\n }\n },\n });\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { Gitlab } from '@gitbeaker/node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { DeployTokenScope } from '@gitbeaker/core/dist/types/templates/ResourceDeployTokens';\nimport commonGitlabConfig from '../commonGitlabConfig';\nimport { getToken } from '../util';\nimport { InputError } from '@backstage/errors';\nimport { z } from 'zod';\n\n/**\n * Creates a `gitlab:projectDeployToken:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectDeployTokenAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectDeployToken:create',\n schema: {\n input: commonGitlabConfig.merge(\n z.object({\n projectId: z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n name: z.string({ description: 'Deploy Token Name' }),\n username: z\n .string({ description: 'Deploy Token Username' })\n .optional(),\n scopes: z.array(z.string(), { description: 'Scopes' }).optional(),\n }),\n ),\n output: z.object({\n deploy_token: z.string({ description: 'Deploy Token' }),\n user: z.string({ description: 'User' }),\n }),\n },\n async handler(ctx) {\n ctx.logger.info(`Creating Token for Project \"${ctx.input.projectId}\"`);\n const { projectId, name, username, scopes } = ctx.input;\n const { token, integrationConfig } = getToken(ctx.input, integrations);\n\n const api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n\n const deployToken = await api.ProjectDeployTokens.add(\n projectId,\n name,\n scopes as DeployTokenScope[],\n {\n username: username,\n },\n );\n\n if (!deployToken.hasOwnProperty('token')) {\n throw new InputError(`No deploy_token given from gitlab instance`);\n }\n\n ctx.output('deploy_token', deployToken.token as string);\n ctx.output('user', deployToken.username);\n },\n });\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport commonGitlabConfig from '../commonGitlabConfig';\nimport { getToken } from '../util';\nimport { z } from 'zod';\n\n/**\n * Creates a `gitlab:projectAccessToken:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectAccessTokenAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectAccessToken:create',\n schema: {\n input: commonGitlabConfig.merge(\n z.object({\n projectId: z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n name: z.string({ description: 'Deploy Token Name' }).optional(),\n accessLevel: z\n .number({ description: 'Access Level of the Token' })\n .optional(),\n scopes: z.array(z.string(), { description: 'Scopes' }).optional(),\n }),\n ),\n output: z.object({\n access_token: z.string({ description: 'Access Token' }),\n }),\n },\n async handler(ctx) {\n ctx.logger.info(`Creating Token for Project \"${ctx.input.projectId}\"`);\n const { projectId, name, accessLevel, scopes } = ctx.input;\n const { token, integrationConfig } = getToken(ctx.input, integrations);\n\n const response = await fetch(\n `${integrationConfig.config.baseUrl}/api/v4/projects/${projectId}/access_tokens`,\n {\n method: 'POST', // *GET, POST, PUT, DELETE, etc.\n headers: {\n 'PRIVATE-TOKEN': token,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n name: name,\n scopes: scopes,\n access_level: accessLevel,\n }),\n },\n );\n\n const result = await response.json();\n\n ctx.output('access_token', result.token);\n },\n });\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { Gitlab } from '@gitbeaker/node';\nimport { getToken } from '../util';\nimport commonGitlabConfig from '../commonGitlabConfig';\nimport { z } from 'zod';\n\n/**\n * Creates a `gitlab:projectVariable:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectVariableAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectVariable:create',\n schema: {\n input: commonGitlabConfig.merge(\n z.object({\n projectId: z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n key: z\n .string({\n description:\n 'The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed',\n })\n .regex(/^[A-Za-z0-9_]{1,255}$/),\n value: z.string({ description: 'The value of a variable' }),\n variableType: z.string({\n description: 'Variable Type (env_var or file)',\n }),\n variableProtected: z\n .boolean({ description: 'Whether the variable is protected' })\n .default(false)\n .optional(),\n masked: z\n .boolean({ description: 'Whether the variable is masked' })\n .default(false)\n .optional(),\n raw: z\n .boolean({ description: 'Whether the variable is expandable' })\n .default(false)\n .optional(),\n environmentScope: z\n .string({ description: 'The environment_scope of the variable' })\n .default('*')\n .optional(),\n }),\n ),\n },\n async handler(ctx) {\n const {\n projectId,\n key,\n value,\n variableType,\n variableProtected = false,\n masked = false,\n raw = false,\n environmentScope = '*',\n } = ctx.input;\n const { token, integrationConfig } = getToken(ctx.input, integrations);\n\n const api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n\n await api.ProjectVariables.create(projectId, {\n key: key,\n value: value,\n variable_type: variableType,\n protected: variableProtected,\n masked: masked,\n raw: raw,\n environment_scope: environmentScope,\n });\n },\n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M,MAAA;AAAA,QACJ,SAAA;AAAA,QACA,GAAA;AAAA,QACA,KAAA;AAAA,QACA,YAAA;AAAA,QACA,iBAAoB,GAAA,KAAA;AAAA,QACpB,MAAS,GAAA,KAAA;AAAA,QACT,GAAM,GAAA,KAAA;AAAA,QACN,gBAAmB,GAAA,GAAA;AAAA,UACjB,GAAI,CAAA,KAAA,CAAA;AACR,MAAA,MAAM,EAAE,KAAO,EAAA,iBAAA,KAAsB,QAAS,CAAA,GAAA,CAAI,OAAO,YAAY,CAAA,CAAA;AAErE,MAAM,MAAA,GAAA,GAAM,IAAIG,WAAO,CAAA;AAAA,QACrB,IAAA,EAAM,kBAAkB,MAAO,CAAA,OAAA;AAAA,QAC/B,KAAA;AAAA,OACD,CAAA,CAAA;AAED,MAAM,MAAA,GAAA,CAAI,gBAAiB,CAAA,MAAA,CAAO,SAAW,EAAA;AAAA,QAC3C,GAAA;AAAA,QACA,KAAA;AAAA,QACA,aAAe,EAAA,YAAA;AAAA,QACf,SAAW,EAAA,iBAAA;AAAA,QACX,MAAA;AAAA,QACA,GAAA;AAAA,QACA,iBAAmB,EAAA,gBAAA;AAAA,OACpB,CAAA,CAAA;AAAA,KACH;AAAA,GACD,CAAA,CAAA;AACH;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,24 @@
1
1
  import * as _backstage_plugin_scaffolder_node from '@backstage/plugin-scaffolder-node';
2
- import * as _backstage_types from '@backstage/types';
3
2
  import { ScmIntegrationRegistry } from '@backstage/integration';
3
+ import * as _backstage_types from '@backstage/types';
4
+
5
+ /**
6
+ * Creates an `gitlab:group:ensureExists` Scaffolder action.
7
+ *
8
+ * @public
9
+ */
10
+ declare const createGitlabGroupEnsureExistsAction: (options: {
11
+ integrations: ScmIntegrationRegistry;
12
+ }) => _backstage_plugin_scaffolder_node.TemplateAction<{
13
+ path: string[];
14
+ repoUrl: string;
15
+ token?: string | undefined;
16
+ }, {
17
+ groupId?: number | undefined;
18
+ }>;
4
19
 
5
20
  /**
6
- * Creates a `gitlab:create-project-deploy-token` Scaffolder action.
21
+ * Creates a `gitlab:projectDeployToken:create` Scaffolder action.
7
22
  *
8
23
  * @param options - Templating configuration.
9
24
  * @public
@@ -11,16 +26,19 @@ import { ScmIntegrationRegistry } from '@backstage/integration';
11
26
  declare const createGitlabProjectDeployTokenAction: (options: {
12
27
  integrations: ScmIntegrationRegistry;
13
28
  }) => _backstage_plugin_scaffolder_node.TemplateAction<{
14
- repoUrl: string;
15
- projectId: string | number;
16
29
  name: string;
17
- username: string;
18
- scopes: string[];
30
+ projectId: string | number;
31
+ repoUrl: string;
19
32
  token?: string | undefined;
20
- }, _backstage_types.JsonObject>;
33
+ username?: string | undefined;
34
+ scopes?: string[] | undefined;
35
+ }, {
36
+ user: string;
37
+ deploy_token: string;
38
+ }>;
21
39
 
22
40
  /**
23
- * Creates a `gitlab:create-project-access-token` Scaffolder action.
41
+ * Creates a `gitlab:projectAccessToken:create` Scaffolder action.
24
42
  *
25
43
  * @param options - Templating configuration.
26
44
  * @public
@@ -28,16 +46,18 @@ declare const createGitlabProjectDeployTokenAction: (options: {
28
46
  declare const createGitlabProjectAccessTokenAction: (options: {
29
47
  integrations: ScmIntegrationRegistry;
30
48
  }) => _backstage_plugin_scaffolder_node.TemplateAction<{
31
- repoUrl: string;
32
49
  projectId: string | number;
33
- name: string;
34
- accessLevel: number;
35
- scopes: string[];
50
+ repoUrl: string;
36
51
  token?: string | undefined;
37
- }, _backstage_types.JsonObject>;
52
+ name?: string | undefined;
53
+ accessLevel?: number | undefined;
54
+ scopes?: string[] | undefined;
55
+ }, {
56
+ access_token: string;
57
+ }>;
38
58
 
39
59
  /**
40
- * Creates a `gitlab:create-project-variable` Scaffolder action.
60
+ * Creates a `gitlab:projectVariable:create` Scaffolder action.
41
61
  *
42
62
  * @param options - Templating configuration.
43
63
  * @public
@@ -45,16 +65,16 @@ declare const createGitlabProjectAccessTokenAction: (options: {
45
65
  declare const createGitlabProjectVariableAction: (options: {
46
66
  integrations: ScmIntegrationRegistry;
47
67
  }) => _backstage_plugin_scaffolder_node.TemplateAction<{
48
- repoUrl: string;
49
- projectId: string | number;
50
68
  key: string;
51
69
  value: string;
70
+ projectId: string | number;
71
+ repoUrl: string;
52
72
  variableType: string;
53
- variableProtected: boolean;
54
- masked: boolean;
55
- raw: boolean;
56
- environmentScope: string;
57
73
  token?: string | undefined;
74
+ variableProtected?: boolean | undefined;
75
+ masked?: boolean | undefined;
76
+ raw?: boolean | undefined;
77
+ environmentScope?: string | undefined;
58
78
  }, _backstage_types.JsonObject>;
59
79
 
60
- export { createGitlabProjectAccessTokenAction, createGitlabProjectDeployTokenAction, createGitlabProjectVariableAction };
80
+ export { createGitlabGroupEnsureExistsAction, createGitlabProjectAccessTokenAction, createGitlabProjectDeployTokenAction, createGitlabProjectVariableAction };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-gitlab",
3
- "version": "0.1.1-next.1",
3
+ "version": "0.2.0",
4
4
  "main": "dist/index.esm.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -33,14 +33,15 @@
33
33
  "dependencies": {
34
34
  "@backstage/config": "^1.0.7",
35
35
  "@backstage/errors": "^1.1.5",
36
- "@backstage/integration": "^1.4.5-next.0",
37
- "@backstage/plugin-scaffolder-node": "^0.1.3-next.1",
38
- "@gitbeaker/node": "^35.8.0"
36
+ "@backstage/integration": "^1.4.5",
37
+ "@backstage/plugin-scaffolder-node": "^0.1.3",
38
+ "@gitbeaker/node": "^35.8.0",
39
+ "zod": "^3.21.4"
39
40
  },
40
41
  "devDependencies": {
41
- "@backstage/backend-common": "^0.18.5-next.1",
42
- "@backstage/cli": "^0.22.7-next.0",
43
- "@backstage/core-app-api": "^1.8.0-next.1"
42
+ "@backstage/backend-common": "^0.18.5",
43
+ "@backstage/cli": "^0.22.7",
44
+ "@backstage/core-app-api": "^1.8.0"
44
45
  },
45
46
  "files": [
46
47
  "dist"