@backstage/plugin-scaffolder-backend-module-gerrit 0.1.0-next.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 ADDED
@@ -0,0 +1,15 @@
1
+ # @backstage/plugin-scaffolder-backend-module-gerrit
2
+
3
+ ## 0.1.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 219d7f0: Create new scaffolder module for external integrations
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @backstage/plugin-scaffolder-node@0.2.9-next.3
13
+ - @backstage/config@1.1.1
14
+ - @backstage/errors@1.2.3
15
+ - @backstage/integration@1.8.0-next.1
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @backstage/plugin-scaffolder-backend-module-gerrit
2
+
3
+ The gerrit module for [@backstage/plugin-scaffolder-backend](https://www.npmjs.com/package/@backstage/plugin-scaffolder-backend).
4
+
5
+ _This plugin was created through the Backstage CLI_
@@ -0,0 +1,417 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var crypto = require('crypto');
6
+ var errors = require('@backstage/errors');
7
+ var integration = require('@backstage/integration');
8
+ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
9
+ var fetch = require('node-fetch');
10
+ var yaml = require('yaml');
11
+
12
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
+
14
+ var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
15
+ var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
16
+ var yaml__default = /*#__PURE__*/_interopDefaultLegacy(yaml);
17
+
18
+ const examples = [
19
+ {
20
+ description: "Initializes a Gerrit repository of contents in workspace and publish it to Gerrit with default configuration.",
21
+ example: yaml__default["default"].stringify({
22
+ steps: [
23
+ {
24
+ id: "publish",
25
+ action: "publish:gerrit",
26
+ name: "Publish to Gerrit",
27
+ input: {
28
+ repoUrl: "gerrit.com?repo=repo&owner=owner"
29
+ }
30
+ }
31
+ ]
32
+ })
33
+ },
34
+ {
35
+ description: "Initializes a Gerrit repository with a description.",
36
+ example: yaml__default["default"].stringify({
37
+ steps: [
38
+ {
39
+ id: "publish",
40
+ action: "publish:gerrit",
41
+ name: "Publish to Gerrit",
42
+ input: {
43
+ repoUrl: "gerrit.com?repo=repo&owner=owner",
44
+ description: "Initialize a gerrit repository"
45
+ }
46
+ }
47
+ ]
48
+ })
49
+ },
50
+ {
51
+ description: "Initializes a Gerrit repository with a default Branch, if not set defaults to master",
52
+ example: yaml__default["default"].stringify({
53
+ steps: [
54
+ {
55
+ id: "publish",
56
+ action: "publish:gerrit",
57
+ name: "Publish to Gerrit",
58
+ input: {
59
+ repoUrl: "gerrit.com?repo=repo&owner=owner",
60
+ defaultBranch: "staging"
61
+ }
62
+ }
63
+ ]
64
+ })
65
+ },
66
+ {
67
+ description: "Initializes a Gerrit repository with an initial commit message, if not set defaults to initial commit",
68
+ example: yaml__default["default"].stringify({
69
+ steps: [
70
+ {
71
+ id: "publish",
72
+ action: "publish:gerrit",
73
+ name: "Publish to Gerrit",
74
+ input: {
75
+ repoUrl: "gerrit.com?repo=repo&owner=owner",
76
+ gitCommitMessage: "Initial Commit Message"
77
+ }
78
+ }
79
+ ]
80
+ })
81
+ },
82
+ {
83
+ description: "Initializes a Gerrit repository with a repo Author Name, if not set defaults to Scaffolder",
84
+ example: yaml__default["default"].stringify({
85
+ steps: [
86
+ {
87
+ id: "publish",
88
+ action: "publish:gerrit",
89
+ name: "Publish to Gerrit",
90
+ input: {
91
+ repoUrl: "gerrit.com?repo=repo&owner=owner",
92
+ gitAuthorName: "John Doe"
93
+ }
94
+ }
95
+ ]
96
+ })
97
+ },
98
+ {
99
+ description: "Initializes a Gerrit repository with a repo Author Email",
100
+ example: yaml__default["default"].stringify({
101
+ steps: [
102
+ {
103
+ id: "publish",
104
+ action: "publish:gerrit",
105
+ name: "Publish to Gerrit",
106
+ input: {
107
+ repoUrl: "gerrit.com?repo=repo&owner=owner",
108
+ gitAuthorEmail: "johndoe@email.com"
109
+ }
110
+ }
111
+ ]
112
+ })
113
+ },
114
+ {
115
+ description: "Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository",
116
+ example: yaml__default["default"].stringify({
117
+ steps: [
118
+ {
119
+ id: "publish",
120
+ action: "publish:gerrit",
121
+ name: "Publish to Gerrit",
122
+ input: {
123
+ repoUrl: "gerrit.com?repo=repo&owner=owner",
124
+ sourcePath: "repository/"
125
+ }
126
+ }
127
+ ]
128
+ })
129
+ },
130
+ {
131
+ description: "Initializes a Gerrit repository with all proporties being set",
132
+ example: yaml__default["default"].stringify({
133
+ steps: [
134
+ {
135
+ id: "publish",
136
+ action: "publish:gerrit",
137
+ name: "Publish to Gerrit",
138
+ input: {
139
+ repoUrl: "gerrit.com?repo=repo&owner=owner",
140
+ description: "Initialize a gerrit repository",
141
+ defaultBranch: "staging",
142
+ gitCommitMessage: "Initial Commit Message",
143
+ gitAuthorName: "John Doe",
144
+ gitAuthorEmail: "johndoe@email.com",
145
+ sourcePath: "repository/"
146
+ }
147
+ }
148
+ ]
149
+ })
150
+ }
151
+ ];
152
+
153
+ const createGerritProject = async (config, options) => {
154
+ const { projectName, parent, owner, description } = options;
155
+ const fetchOptions = {
156
+ method: "PUT",
157
+ body: JSON.stringify({
158
+ parent,
159
+ description,
160
+ owners: owner ? [owner] : [],
161
+ create_empty_commit: false
162
+ }),
163
+ headers: {
164
+ ...integration.getGerritRequestOptions(config).headers,
165
+ "Content-Type": "application/json"
166
+ }
167
+ };
168
+ const response = await fetch__default["default"](
169
+ `${config.baseUrl}/a/projects/${encodeURIComponent(projectName)}`,
170
+ fetchOptions
171
+ );
172
+ if (response.status !== 201) {
173
+ throw new Error(
174
+ `Unable to create repository, ${response.status} ${response.statusText}, ${await response.text()}`
175
+ );
176
+ }
177
+ };
178
+ const generateCommitMessage = (config, commitSubject) => {
179
+ const changeId = crypto__default["default"].randomBytes(20).toString("hex");
180
+ const msg = `${config.getOptionalString("scaffolder.defaultCommitMessage") || commitSubject}
181
+
182
+ Change-Id: I${changeId}`;
183
+ return msg;
184
+ };
185
+ function createPublishGerritAction(options) {
186
+ const { integrations, config } = options;
187
+ return pluginScaffolderNode.createTemplateAction({
188
+ id: "publish:gerrit",
189
+ description: "Initializes a git repository of the content in the workspace, and publishes it to Gerrit.",
190
+ examples,
191
+ schema: {
192
+ input: {
193
+ type: "object",
194
+ required: ["repoUrl"],
195
+ properties: {
196
+ repoUrl: {
197
+ title: "Repository Location",
198
+ type: "string"
199
+ },
200
+ description: {
201
+ title: "Repository Description",
202
+ type: "string"
203
+ },
204
+ defaultBranch: {
205
+ title: "Default Branch",
206
+ type: "string",
207
+ description: `Sets the default branch on the repository. The default value is 'master'`
208
+ },
209
+ gitCommitMessage: {
210
+ title: "Git Commit Message",
211
+ type: "string",
212
+ description: `Sets the commit message on the repository. The default value is 'initial commit'`
213
+ },
214
+ gitAuthorName: {
215
+ title: "Default Author Name",
216
+ type: "string",
217
+ description: `Sets the default author name for the commit. The default value is 'Scaffolder'`
218
+ },
219
+ gitAuthorEmail: {
220
+ title: "Default Author Email",
221
+ type: "string",
222
+ description: `Sets the default author email for the commit.`
223
+ },
224
+ sourcePath: {
225
+ title: "Source Path",
226
+ type: "string",
227
+ description: `Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.`
228
+ }
229
+ }
230
+ },
231
+ output: {
232
+ type: "object",
233
+ properties: {
234
+ remoteUrl: {
235
+ title: "A URL to the repository with the provider",
236
+ type: "string"
237
+ },
238
+ repoContentsUrl: {
239
+ title: "A URL to the root of the repository",
240
+ type: "string"
241
+ },
242
+ commitHash: {
243
+ title: "The git commit hash of the initial commit",
244
+ type: "string"
245
+ }
246
+ }
247
+ }
248
+ },
249
+ async handler(ctx) {
250
+ const {
251
+ repoUrl,
252
+ description,
253
+ defaultBranch = "master",
254
+ gitAuthorName,
255
+ gitAuthorEmail,
256
+ gitCommitMessage = "initial commit",
257
+ sourcePath
258
+ } = ctx.input;
259
+ const { repo, host, owner, workspace } = pluginScaffolderNode.parseRepoUrl(
260
+ repoUrl,
261
+ integrations
262
+ );
263
+ const integrationConfig = integrations.gerrit.byHost(host);
264
+ if (!integrationConfig) {
265
+ throw new errors.InputError(
266
+ `No matching integration configuration for host ${host}, please check your integrations config`
267
+ );
268
+ }
269
+ if (!workspace) {
270
+ throw new errors.InputError(
271
+ `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`
272
+ );
273
+ }
274
+ await createGerritProject(integrationConfig.config, {
275
+ description,
276
+ owner,
277
+ projectName: repo,
278
+ parent: workspace
279
+ });
280
+ const auth = {
281
+ username: integrationConfig.config.username,
282
+ password: integrationConfig.config.password
283
+ };
284
+ const gitAuthorInfo = {
285
+ name: gitAuthorName ? gitAuthorName : config.getOptionalString("scaffolder.defaultAuthor.name"),
286
+ email: gitAuthorEmail ? gitAuthorEmail : config.getOptionalString("scaffolder.defaultAuthor.email")
287
+ };
288
+ const remoteUrl = `${integrationConfig.config.cloneUrl}/a/${repo}`;
289
+ const commitResult = await pluginScaffolderNode.initRepoAndPush({
290
+ dir: pluginScaffolderNode.getRepoSourceDirectory(ctx.workspacePath, sourcePath),
291
+ remoteUrl,
292
+ auth,
293
+ defaultBranch,
294
+ logger: ctx.logger,
295
+ commitMessage: generateCommitMessage(config, gitCommitMessage),
296
+ gitAuthorInfo
297
+ });
298
+ const repoContentsUrl = `${integrationConfig.config.gitilesBaseUrl}/${repo}/+/refs/heads/${defaultBranch}`;
299
+ ctx.output("remoteUrl", remoteUrl);
300
+ ctx.output("commitHash", commitResult == null ? void 0 : commitResult.commitHash);
301
+ ctx.output("repoContentsUrl", repoContentsUrl);
302
+ }
303
+ });
304
+ }
305
+
306
+ const generateGerritChangeId = () => {
307
+ const changeId = crypto__default["default"].randomBytes(20).toString("hex");
308
+ return `I${changeId}`;
309
+ };
310
+ function createPublishGerritReviewAction(options) {
311
+ const { integrations, config } = options;
312
+ return pluginScaffolderNode.createTemplateAction({
313
+ id: "publish:gerrit:review",
314
+ description: "Creates a new Gerrit review.",
315
+ schema: {
316
+ input: {
317
+ type: "object",
318
+ required: ["repoUrl", "gitCommitMessage"],
319
+ properties: {
320
+ repoUrl: {
321
+ title: "Repository Location",
322
+ type: "string"
323
+ },
324
+ branch: {
325
+ title: "Repository branch",
326
+ type: "string",
327
+ description: "Branch of the repository the review will be created on"
328
+ },
329
+ sourcePath: {
330
+ type: "string",
331
+ title: "Working Subdirectory",
332
+ description: "Subdirectory of working directory containing the repository"
333
+ },
334
+ gitCommitMessage: {
335
+ title: "Git Commit Message",
336
+ type: "string",
337
+ description: `Sets the commit message on the repository.`
338
+ },
339
+ gitAuthorName: {
340
+ title: "Default Author Name",
341
+ type: "string",
342
+ description: `Sets the default author name for the commit. The default value is 'Scaffolder'`
343
+ },
344
+ gitAuthorEmail: {
345
+ title: "Default Author Email",
346
+ type: "string",
347
+ description: `Sets the default author email for the commit.`
348
+ }
349
+ }
350
+ },
351
+ output: {
352
+ type: "object",
353
+ properties: {
354
+ reviewUrl: {
355
+ title: "A URL to the review",
356
+ type: "string"
357
+ },
358
+ repoContentsUrl: {
359
+ title: "A URL to the root of the repository",
360
+ type: "string"
361
+ }
362
+ }
363
+ }
364
+ },
365
+ async handler(ctx) {
366
+ var _a;
367
+ const {
368
+ repoUrl,
369
+ branch = "master",
370
+ sourcePath,
371
+ gitAuthorName,
372
+ gitAuthorEmail,
373
+ gitCommitMessage
374
+ } = ctx.input;
375
+ const { host, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
376
+ if (!gitCommitMessage) {
377
+ throw new errors.InputError(`Missing gitCommitMessage input`);
378
+ }
379
+ const integrationConfig = integrations.gerrit.byHost(host);
380
+ if (!integrationConfig) {
381
+ throw new errors.InputError(
382
+ `No matching integration configuration for host ${host}, please check your integrations config`
383
+ );
384
+ }
385
+ const auth = {
386
+ username: integrationConfig.config.username,
387
+ password: integrationConfig.config.password
388
+ };
389
+ const gitAuthorInfo = {
390
+ name: gitAuthorName ? gitAuthorName : config.getOptionalString("scaffolder.defaultAuthor.name"),
391
+ email: gitAuthorEmail ? gitAuthorEmail : config.getOptionalString("scaffolder.defaultAuthor.email")
392
+ };
393
+ const changeId = generateGerritChangeId();
394
+ const commitMessage = `${gitCommitMessage}
395
+
396
+ Change-Id: ${changeId}`;
397
+ await pluginScaffolderNode.commitAndPushRepo({
398
+ dir: pluginScaffolderNode.getRepoSourceDirectory(ctx.workspacePath, sourcePath),
399
+ auth,
400
+ logger: ctx.logger,
401
+ commitMessage,
402
+ gitAuthorInfo,
403
+ branch,
404
+ remoteRef: `refs/for/${branch}`
405
+ });
406
+ const repoContentsUrl = `${integrationConfig.config.gitilesBaseUrl}/${repo}/+/refs/heads/${branch}`;
407
+ const reviewUrl = `${integrationConfig.config.baseUrl}/#/q/${changeId}`;
408
+ (_a = ctx.logger) == null ? void 0 : _a.info(`Review available on ${reviewUrl}`);
409
+ ctx.output("repoContentsUrl", repoContentsUrl);
410
+ ctx.output("reviewUrl", reviewUrl);
411
+ }
412
+ });
413
+ }
414
+
415
+ exports.createPublishGerritAction = createPublishGerritAction;
416
+ exports.createPublishGerritReviewAction = createPublishGerritReviewAction;
417
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/actions/gerrit.examples.ts","../src/actions/gerrit.ts","../src/actions/gerritReview.ts"],"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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Initializes a Gerrit repository of contents in workspace and publish it to Gerrit with default configuration.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a Gerrit repository with a description.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n description: 'Initialize a gerrit repository',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Gerrit repository with a default Branch, if not set defaults to master',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n defaultBranch: 'staging',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Gerrit repository with an initial commit message, if not set defaults to initial commit',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n gitCommitMessage: 'Initial Commit Message',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Gerrit repository with a repo Author Name, if not set defaults to Scaffolder',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n gitAuthorName: 'John Doe',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a Gerrit repository with a repo Author Email',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n gitAuthorEmail: 'johndoe@email.com',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n sourcePath: 'repository/',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Gerrit repository with all proporties being set',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n description: 'Initialize a gerrit repository',\n defaultBranch: 'staging',\n gitCommitMessage: 'Initial Commit Message',\n gitAuthorName: 'John Doe',\n gitAuthorEmail: 'johndoe@email.com',\n sourcePath: 'repository/',\n },\n },\n ],\n }),\n },\n];\n","/*\n * Copyright 2022 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 crypto from 'crypto';\nimport { InputError } from '@backstage/errors';\nimport { Config } from '@backstage/config';\nimport {\n GerritIntegrationConfig,\n getGerritRequestOptions,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n initRepoAndPush,\n getRepoSourceDirectory,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport fetch, { Response, RequestInit } from 'node-fetch';\nimport { examples } from './gerrit.examples';\n\nconst createGerritProject = async (\n config: GerritIntegrationConfig,\n options: {\n projectName: string;\n parent: string;\n owner?: string;\n description: string;\n },\n): Promise<void> => {\n const { projectName, parent, owner, description } = options;\n\n const fetchOptions: RequestInit = {\n method: 'PUT',\n body: JSON.stringify({\n parent,\n description,\n owners: owner ? [owner] : [],\n create_empty_commit: false,\n }),\n headers: {\n ...getGerritRequestOptions(config).headers,\n 'Content-Type': 'application/json',\n },\n };\n const response: Response = await fetch(\n `${config.baseUrl}/a/projects/${encodeURIComponent(projectName)}`,\n fetchOptions,\n );\n if (response.status !== 201) {\n throw new Error(\n `Unable to create repository, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n};\n\nconst generateCommitMessage = (\n config: Config,\n commitSubject?: string,\n): string => {\n const changeId = crypto.randomBytes(20).toString('hex');\n const msg = `${\n config.getOptionalString('scaffolder.defaultCommitMessage') || commitSubject\n }\\n\\nChange-Id: I${changeId}`;\n return msg;\n};\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to a Gerrit instance.\n * @public\n */\nexport function createPublishGerritAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n description: string;\n defaultBranch?: string;\n gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n sourcePath?: string;\n }>({\n id: 'publish:gerrit',\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to Gerrit.',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n description: {\n title: 'Repository Description',\n type: 'string',\n },\n defaultBranch: {\n title: 'Default Branch',\n type: 'string',\n description: `Sets the default branch on the repository. The default value is 'master'`,\n },\n gitCommitMessage: {\n title: 'Git Commit Message',\n type: 'string',\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n },\n gitAuthorName: {\n title: 'Default Author Name',\n type: 'string',\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n },\n gitAuthorEmail: {\n title: 'Default Author Email',\n type: 'string',\n description: `Sets the default author email for the commit.`,\n },\n sourcePath: {\n title: 'Source Path',\n type: 'string',\n description: `Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.`,\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n remoteUrl: {\n title: 'A URL to the repository with the provider',\n type: 'string',\n },\n repoContentsUrl: {\n title: 'A URL to the root of the repository',\n type: 'string',\n },\n commitHash: {\n title: 'The git commit hash of the initial commit',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n defaultBranch = 'master',\n gitAuthorName,\n gitAuthorEmail,\n gitCommitMessage = 'initial commit',\n sourcePath,\n } = ctx.input;\n const { repo, host, owner, workspace } = parseRepoUrl(\n repoUrl,\n integrations,\n );\n\n const integrationConfig = integrations.gerrit.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 if (!workspace) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`,\n );\n }\n\n await createGerritProject(integrationConfig.config, {\n description,\n owner: owner,\n projectName: repo,\n parent: workspace,\n });\n const auth = {\n username: integrationConfig.config.username!,\n password: integrationConfig.config.password!,\n };\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n const remoteUrl = `${integrationConfig.config.cloneUrl}/a/${repo}`;\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(ctx.workspacePath, sourcePath),\n remoteUrl,\n auth,\n defaultBranch,\n logger: ctx.logger,\n commitMessage: generateCommitMessage(config, gitCommitMessage),\n gitAuthorInfo,\n });\n\n const repoContentsUrl = `${integrationConfig.config.gitilesBaseUrl}/${repo}/+/refs/heads/${defaultBranch}`;\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('repoContentsUrl', repoContentsUrl);\n },\n });\n}\n","/*\n * Copyright 2022 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 crypto from 'crypto';\nimport { InputError } from '@backstage/errors';\nimport { Config } from '@backstage/config';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport {\n createTemplateAction,\n commitAndPushRepo,\n getRepoSourceDirectory,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\n\nconst generateGerritChangeId = (): string => {\n const changeId = crypto.randomBytes(20).toString('hex');\n return `I${changeId}`;\n};\n\n/**\n * Creates a new action that creates a Gerrit review\n * @public\n */\nexport function createPublishGerritReviewAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n branch?: string;\n sourcePath?: string;\n gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n }>({\n id: 'publish:gerrit:review',\n description: 'Creates a new Gerrit review.',\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'gitCommitMessage'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n branch: {\n title: 'Repository branch',\n type: 'string',\n description:\n 'Branch of the repository the review will be created on',\n },\n sourcePath: {\n type: 'string',\n title: 'Working Subdirectory',\n description:\n 'Subdirectory of working directory containing the repository',\n },\n gitCommitMessage: {\n title: 'Git Commit Message',\n type: 'string',\n description: `Sets the commit message on the repository.`,\n },\n gitAuthorName: {\n title: 'Default Author Name',\n type: 'string',\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n },\n gitAuthorEmail: {\n title: 'Default Author Email',\n type: 'string',\n description: `Sets the default author email for the commit.`,\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n reviewUrl: {\n title: 'A URL to the review',\n type: 'string',\n },\n repoContentsUrl: {\n title: 'A URL to the root of the repository',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n branch = 'master',\n sourcePath,\n gitAuthorName,\n gitAuthorEmail,\n gitCommitMessage,\n } = ctx.input;\n const { host, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!gitCommitMessage) {\n throw new InputError(`Missing gitCommitMessage input`);\n }\n\n const integrationConfig = integrations.gerrit.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 auth = {\n username: integrationConfig.config.username!,\n password: integrationConfig.config.password!,\n };\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n const changeId = generateGerritChangeId();\n const commitMessage = `${gitCommitMessage}\\n\\nChange-Id: ${changeId}`;\n\n await commitAndPushRepo({\n dir: getRepoSourceDirectory(ctx.workspacePath, sourcePath),\n auth,\n logger: ctx.logger,\n commitMessage,\n gitAuthorInfo,\n branch,\n remoteRef: `refs/for/${branch}`,\n });\n\n const repoContentsUrl = `${integrationConfig.config.gitilesBaseUrl}/${repo}/+/refs/heads/${branch}`;\n const reviewUrl = `${integrationConfig.config.baseUrl}/#/q/${changeId}`;\n ctx.logger?.info(`Review available on ${reviewUrl}`);\n ctx.output('repoContentsUrl', repoContentsUrl);\n ctx.output('reviewUrl', reviewUrl);\n },\n });\n}\n"],"names":["yaml","getGerritRequestOptions","fetch","crypto","createTemplateAction","parseRepoUrl","InputError","initRepoAndPush","getRepoSourceDirectory","commitAndPushRepo"],"mappings":";;;;;;;;;;;;;;;;;AAmBO,MAAM,QAA8B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;AAAA,OAC9B,CAAA,CAAA;AAED,MAAM,MAAA,eAAA,GAAkB,GAAG,iBAAkB,CAAA,MAAA,CAAO,cAAc,CAAI,CAAA,EAAA,IAAI,iBAAiB,MAAM,CAAA,CAAA,CAAA;AACjG,MAAA,MAAM,YAAY,CAAG,EAAA,iBAAA,CAAkB,MAAO,CAAA,OAAO,QAAQ,QAAQ,CAAA,CAAA,CAAA;AACrE,MAAA,CAAA,EAAA,GAAA,GAAA,CAAI,MAAJ,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAY,IAAK,CAAA,CAAA,oBAAA,EAAuB,SAAS,CAAA,CAAA,CAAA,CAAA;AACjD,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA,CAAA;AAC7C,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA,CAAA;AAAA,KACnC;AAAA,GACD,CAAA,CAAA;AACH;;;;;"}
@@ -0,0 +1,40 @@
1
+ import * as _backstage_plugin_scaffolder_node from '@backstage/plugin-scaffolder-node';
2
+ import * as _backstage_types from '@backstage/types';
3
+ import { Config } from '@backstage/config';
4
+ import { ScmIntegrationRegistry } from '@backstage/integration';
5
+
6
+ /**
7
+ * Creates a new action that initializes a git repository of the content in the workspace
8
+ * and publishes it to a Gerrit instance.
9
+ * @public
10
+ */
11
+ declare function createPublishGerritAction(options: {
12
+ integrations: ScmIntegrationRegistry;
13
+ config: Config;
14
+ }): _backstage_plugin_scaffolder_node.TemplateAction<{
15
+ repoUrl: string;
16
+ description: string;
17
+ defaultBranch?: string | undefined;
18
+ gitCommitMessage?: string | undefined;
19
+ gitAuthorName?: string | undefined;
20
+ gitAuthorEmail?: string | undefined;
21
+ sourcePath?: string | undefined;
22
+ }, _backstage_types.JsonObject>;
23
+
24
+ /**
25
+ * Creates a new action that creates a Gerrit review
26
+ * @public
27
+ */
28
+ declare function createPublishGerritReviewAction(options: {
29
+ integrations: ScmIntegrationRegistry;
30
+ config: Config;
31
+ }): _backstage_plugin_scaffolder_node.TemplateAction<{
32
+ repoUrl: string;
33
+ branch?: string | undefined;
34
+ sourcePath?: string | undefined;
35
+ gitCommitMessage?: string | undefined;
36
+ gitAuthorName?: string | undefined;
37
+ gitAuthorEmail?: string | undefined;
38
+ }, _backstage_types.JsonObject>;
39
+
40
+ export { createPublishGerritAction, createPublishGerritReviewAction };
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@backstage/plugin-scaffolder-backend-module-gerrit",
3
+ "description": "The gerrit module for @backstage/plugin-scaffolder-backend",
4
+ "version": "0.1.0-next.0",
5
+ "main": "dist/index.cjs.js",
6
+ "types": "dist/index.d.ts",
7
+ "license": "Apache-2.0",
8
+ "publishConfig": {
9
+ "access": "public",
10
+ "main": "dist/index.cjs.js",
11
+ "types": "dist/index.d.ts"
12
+ },
13
+ "backstage": {
14
+ "role": "backend-plugin-module"
15
+ },
16
+ "scripts": {
17
+ "start": "backstage-cli package start",
18
+ "build": "backstage-cli package build",
19
+ "lint": "backstage-cli package lint",
20
+ "test": "backstage-cli package test",
21
+ "clean": "backstage-cli package clean",
22
+ "prepack": "backstage-cli package prepack",
23
+ "postpack": "backstage-cli package postpack"
24
+ },
25
+ "dependencies": {
26
+ "@backstage/config": "^1.1.1",
27
+ "@backstage/errors": "^1.2.3",
28
+ "@backstage/integration": "^1.8.0-next.1",
29
+ "@backstage/plugin-scaffolder-node": "^0.2.9-next.3",
30
+ "node-fetch": "^2.6.7",
31
+ "yaml": "^2.0.0"
32
+ },
33
+ "devDependencies": {
34
+ "@backstage/backend-common": "^0.20.0-next.3",
35
+ "@backstage/backend-test-utils": "^0.2.9-next.3",
36
+ "@backstage/cli": "^0.25.0-next.3",
37
+ "msw": "^1.0.0"
38
+ },
39
+ "files": [
40
+ "dist"
41
+ ]
42
+ }