@backstage/plugin-scaffolder-backend-module-bitbucket-cloud 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,23 @@
1
+ # @backstage/plugin-scaffolder-backend-module-bitbucket-cloud
2
+
3
+ ## 0.1.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5eb6882: New scaffolder module `@backstage/plugin-scaffolder-backend-module-bitbucket-cloud`.
8
+
9
+ Extracted from `@backstage/plugin-scaffolder-backend-module-bitbucket`
10
+ and replaces its actions related to Bitbucket Cloud.
11
+
12
+ - `publish:bitbucketCloud`
13
+ - `bitbucket:pipelines:run`
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+ - @backstage/backend-common@0.21.0-next.2
19
+ - @backstage/backend-plugin-api@0.6.10-next.2
20
+ - @backstage/plugin-scaffolder-node@0.3.0-next.2
21
+ - @backstage/config@1.1.1
22
+ - @backstage/errors@1.2.3
23
+ - @backstage/integration@1.9.0-next.0
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @backstage/plugin-scaffolder-backend-module-bitbucket
2
+
3
+ The [Bitbucket Cloud](https://bitbucket.org) module for
4
+ [@backstage/plugin-scaffolder-backend](https://www.npmjs.com/package/@backstage/plugin-scaffolder-backend).
5
+
6
+ _This plugin was created through the Backstage CLI_
7
+
8
+ ## Actions
9
+
10
+ - `publish:bitbucketCloud`
11
+ - `bitbucket:pipelines:run`
@@ -0,0 +1,628 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var errors = require('@backstage/errors');
6
+ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
7
+ var fetch = require('node-fetch');
8
+ var yaml = require('yaml');
9
+ var backendPluginApi = require('@backstage/backend-plugin-api');
10
+ var alpha = require('@backstage/plugin-scaffolder-node/alpha');
11
+ var integration = require('@backstage/integration');
12
+
13
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
+
15
+ var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
16
+ var yaml__default = /*#__PURE__*/_interopDefaultLegacy(yaml);
17
+
18
+ const getAuthorizationHeader = (config) => {
19
+ if (config.username && config.appPassword) {
20
+ const buffer = Buffer.from(
21
+ `${config.username}:${config.appPassword}`,
22
+ "utf8"
23
+ );
24
+ return `Basic ${buffer.toString("base64")}`;
25
+ }
26
+ if (config.token) {
27
+ return `Bearer ${config.token}`;
28
+ }
29
+ throw new Error(
30
+ `Authorization has not been provided for Bitbucket Cloud. Please add either username + appPassword to the Integrations config or a user login auth token`
31
+ );
32
+ };
33
+
34
+ const createRepository = async (opts) => {
35
+ const {
36
+ workspace,
37
+ project,
38
+ repo,
39
+ description,
40
+ repoVisibility,
41
+ mainBranch,
42
+ authorization,
43
+ apiBaseUrl
44
+ } = opts;
45
+ const options = {
46
+ method: "POST",
47
+ body: JSON.stringify({
48
+ scm: "git",
49
+ description,
50
+ is_private: repoVisibility === "private",
51
+ project: { key: project }
52
+ }),
53
+ headers: {
54
+ Authorization: authorization,
55
+ "Content-Type": "application/json"
56
+ }
57
+ };
58
+ let response;
59
+ try {
60
+ response = await fetch__default["default"](
61
+ `${apiBaseUrl}/repositories/${workspace}/${repo}`,
62
+ options
63
+ );
64
+ } catch (e) {
65
+ throw new Error(`Unable to create repository, ${e}`);
66
+ }
67
+ if (response.status !== 200) {
68
+ throw new Error(
69
+ `Unable to create repository, ${response.status} ${response.statusText}, ${await response.text()}`
70
+ );
71
+ }
72
+ const r = await response.json();
73
+ let remoteUrl = "";
74
+ for (const link of r.links.clone) {
75
+ if (link.name === "https") {
76
+ remoteUrl = link.href;
77
+ }
78
+ }
79
+ const repoContentsUrl = `${r.links.html.href}/src/${mainBranch}`;
80
+ return { remoteUrl, repoContentsUrl };
81
+ };
82
+ function createPublishBitbucketCloudAction(options) {
83
+ const { integrations, config } = options;
84
+ return pluginScaffolderNode.createTemplateAction({
85
+ id: "publish:bitbucketCloud",
86
+ description: "Initializes a git repository of the content in the workspace, and publishes it to Bitbucket Cloud.",
87
+ schema: {
88
+ input: {
89
+ type: "object",
90
+ required: ["repoUrl"],
91
+ properties: {
92
+ repoUrl: {
93
+ title: "Repository Location",
94
+ type: "string"
95
+ },
96
+ description: {
97
+ title: "Repository Description",
98
+ type: "string"
99
+ },
100
+ repoVisibility: {
101
+ title: "Repository Visibility",
102
+ type: "string",
103
+ enum: ["private", "public"]
104
+ },
105
+ defaultBranch: {
106
+ title: "Default Branch",
107
+ type: "string",
108
+ description: `Sets the default branch on the repository. The default value is 'master'`
109
+ },
110
+ sourcePath: {
111
+ title: "Source Path",
112
+ description: "Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.",
113
+ type: "string"
114
+ },
115
+ token: {
116
+ title: "Authentication Token",
117
+ type: "string",
118
+ description: "The token to use for authorization to BitBucket Cloud"
119
+ }
120
+ }
121
+ },
122
+ output: {
123
+ type: "object",
124
+ properties: {
125
+ remoteUrl: {
126
+ title: "A URL to the repository with the provider",
127
+ type: "string"
128
+ },
129
+ repoContentsUrl: {
130
+ title: "A URL to the root of the repository",
131
+ type: "string"
132
+ },
133
+ commitHash: {
134
+ title: "The git commit hash of the initial commit",
135
+ type: "string"
136
+ }
137
+ }
138
+ }
139
+ },
140
+ async handler(ctx) {
141
+ const {
142
+ repoUrl,
143
+ description,
144
+ defaultBranch = "master",
145
+ repoVisibility = "private"
146
+ } = ctx.input;
147
+ const { workspace, project, repo, host } = pluginScaffolderNode.parseRepoUrl(
148
+ repoUrl,
149
+ integrations
150
+ );
151
+ if (!workspace) {
152
+ throw new errors.InputError(
153
+ `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`
154
+ );
155
+ }
156
+ if (!project) {
157
+ throw new errors.InputError(
158
+ `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing project`
159
+ );
160
+ }
161
+ const integrationConfig = integrations.bitbucketCloud.byHost(host);
162
+ if (!integrationConfig) {
163
+ throw new errors.InputError(
164
+ `No matching integration configuration for host ${host}, please check your integrations config`
165
+ );
166
+ }
167
+ const authorization = getAuthorizationHeader(
168
+ ctx.input.token ? { token: ctx.input.token } : integrationConfig.config
169
+ );
170
+ const apiBaseUrl = integrationConfig.config.apiBaseUrl;
171
+ const { remoteUrl, repoContentsUrl } = await createRepository({
172
+ authorization,
173
+ workspace: workspace || "",
174
+ project,
175
+ repo,
176
+ repoVisibility,
177
+ mainBranch: defaultBranch,
178
+ description,
179
+ apiBaseUrl
180
+ });
181
+ const gitAuthorInfo = {
182
+ name: config.getOptionalString("scaffolder.defaultAuthor.name"),
183
+ email: config.getOptionalString("scaffolder.defaultAuthor.email")
184
+ };
185
+ let auth;
186
+ if (ctx.input.token) {
187
+ auth = {
188
+ username: "x-token-auth",
189
+ password: ctx.input.token
190
+ };
191
+ } else {
192
+ if (!integrationConfig.config.username || !integrationConfig.config.appPassword) {
193
+ throw new Error(
194
+ "Credentials for Bitbucket Cloud integration required for this action."
195
+ );
196
+ }
197
+ auth = {
198
+ username: integrationConfig.config.username,
199
+ password: integrationConfig.config.appPassword
200
+ };
201
+ }
202
+ const commitResult = await pluginScaffolderNode.initRepoAndPush({
203
+ dir: pluginScaffolderNode.getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),
204
+ remoteUrl,
205
+ auth,
206
+ defaultBranch,
207
+ logger: ctx.logger,
208
+ commitMessage: config.getOptionalString(
209
+ "scaffolder.defaultCommitMessage"
210
+ ),
211
+ gitAuthorInfo
212
+ });
213
+ ctx.output("commitHash", commitResult == null ? void 0 : commitResult.commitHash);
214
+ ctx.output("remoteUrl", remoteUrl);
215
+ ctx.output("repoContentsUrl", repoContentsUrl);
216
+ }
217
+ });
218
+ }
219
+
220
+ const examples = [
221
+ {
222
+ description: "Trigger a pipeline for a branch",
223
+ example: yaml__default["default"].stringify({
224
+ steps: [
225
+ {
226
+ action: "bitbucket:pipelines:run",
227
+ id: "run-bitbucket-pipeline",
228
+ name: "Run an example bitbucket pipeline",
229
+ input: {
230
+ workspace: "test-workspace",
231
+ repo_slug: "test-repo-slug",
232
+ body: {
233
+ target: {
234
+ ref_type: "branch",
235
+ type: "pipeline_ref_target",
236
+ ref_name: "master"
237
+ }
238
+ }
239
+ }
240
+ }
241
+ ]
242
+ })
243
+ },
244
+ {
245
+ description: "Trigger a pipeline for a commit on a branch",
246
+ example: yaml__default["default"].stringify({
247
+ steps: [
248
+ {
249
+ action: "bitbucket:pipelines:run",
250
+ id: "run-bitbucket-pipeline",
251
+ name: "Run an example bitbucket pipeline",
252
+ input: {
253
+ workspace: "test-workspace",
254
+ repo_slug: "test-repo-slug",
255
+ body: {
256
+ target: {
257
+ commit: {
258
+ type: "commit",
259
+ hash: "ce5b7431602f7cbba007062eeb55225c6e18e956"
260
+ },
261
+ ref_type: "branch",
262
+ type: "pipeline_ref_target",
263
+ ref_name: "master"
264
+ }
265
+ }
266
+ }
267
+ }
268
+ ]
269
+ })
270
+ },
271
+ {
272
+ description: "Trigger a specific pipeline definition for a commit",
273
+ example: yaml__default["default"].stringify({
274
+ steps: [
275
+ {
276
+ action: "bitbucket:pipelines:run",
277
+ id: "run-bitbucket-pipeline",
278
+ name: "Run an example bitbucket pipeline",
279
+ input: {
280
+ workspace: "test-workspace",
281
+ repo_slug: "test-repo-slug",
282
+ body: {
283
+ target: {
284
+ commit: {
285
+ type: "commit",
286
+ hash: "a3c4e02c9a3755eccdc3764e6ea13facdf30f923"
287
+ },
288
+ selector: {
289
+ type: "custom",
290
+ pattern: "Deploy to production"
291
+ },
292
+ type: "pipeline_commit_target"
293
+ }
294
+ }
295
+ }
296
+ }
297
+ ]
298
+ })
299
+ },
300
+ {
301
+ description: "Trigger a specific pipeline definition for a commit on a branch or tag",
302
+ example: yaml__default["default"].stringify({
303
+ steps: [
304
+ {
305
+ action: "bitbucket:pipelines:run",
306
+ id: "run-bitbucket-pipeline",
307
+ name: "Run an example bitbucket pipeline",
308
+ input: {
309
+ workspace: "test-workspace",
310
+ repo_slug: "test-repo-slug",
311
+ body: {
312
+ target: {
313
+ commit: {
314
+ type: "commit",
315
+ hash: "a3c4e02c9a3755eccdc3764e6ea13facdf30f923"
316
+ },
317
+ selector: {
318
+ type: "custom",
319
+ pattern: "Deploy to production"
320
+ },
321
+ type: "pipeline_ref_target",
322
+ ref_name: "master",
323
+ ref_type: "branch"
324
+ }
325
+ }
326
+ }
327
+ }
328
+ ]
329
+ })
330
+ },
331
+ {
332
+ description: "Trigger a custom pipeline with variables",
333
+ example: yaml__default["default"].stringify({
334
+ steps: [
335
+ {
336
+ action: "bitbucket:pipelines:run",
337
+ id: "run-bitbucket-pipeline",
338
+ name: "Run an example bitbucket pipeline",
339
+ input: {
340
+ workspace: "test-workspace",
341
+ repo_slug: "test-repo-slug",
342
+ body: {
343
+ target: {
344
+ type: "pipeline_ref_target",
345
+ ref_name: "master",
346
+ ref_type: "branch",
347
+ selector: {
348
+ type: "custom",
349
+ pattern: "Deploy to production"
350
+ }
351
+ },
352
+ variables: [
353
+ { key: "var1key", value: "var1value", secured: true },
354
+ {
355
+ key: "var2key",
356
+ value: "var2value"
357
+ }
358
+ ]
359
+ }
360
+ }
361
+ }
362
+ ]
363
+ })
364
+ },
365
+ {
366
+ description: "Trigger a pull request pipeline",
367
+ example: yaml__default["default"].stringify({
368
+ steps: [
369
+ {
370
+ action: "bitbucket:pipelines:run",
371
+ id: "run-bitbucket-pipeline",
372
+ name: "Run an example bitbucket pipeline",
373
+ input: {
374
+ workspace: "test-workspace",
375
+ repo_slug: "test-repo-slug",
376
+ body: {
377
+ target: {
378
+ type: "pipeline_pullrequest_target",
379
+ source: "pull-request-branch",
380
+ destination: "master",
381
+ destination_commit: {
382
+ hash: "9f848b7"
383
+ },
384
+ commit: {
385
+ hash: "1a372fc"
386
+ },
387
+ pull_request: {
388
+ id: "3"
389
+ },
390
+ selector: {
391
+ type: "pull-requests",
392
+ pattern: "**"
393
+ }
394
+ }
395
+ }
396
+ }
397
+ }
398
+ ]
399
+ })
400
+ }
401
+ ];
402
+
403
+ const workspace = {
404
+ title: "Workspace",
405
+ description: `The workspace name`,
406
+ type: "string"
407
+ };
408
+ const repo_slug = {
409
+ title: "Repository name",
410
+ description: "The repository name",
411
+ type: "string"
412
+ };
413
+ const ref_type = {
414
+ title: "ref_type",
415
+ type: "string"
416
+ };
417
+ const type = {
418
+ title: "type",
419
+ type: "string"
420
+ };
421
+ const ref_name = {
422
+ title: "ref_name",
423
+ type: "string"
424
+ };
425
+ const source = {
426
+ title: "source",
427
+ type: "string"
428
+ };
429
+ const destination = {
430
+ title: "destination",
431
+ type: "string"
432
+ };
433
+ const hash = {
434
+ title: "hash",
435
+ type: "string"
436
+ };
437
+ const pattern = {
438
+ title: "pattern",
439
+ type: "string"
440
+ };
441
+ const id$1 = {
442
+ title: "id",
443
+ type: "string"
444
+ };
445
+ const key = {
446
+ title: "key",
447
+ type: "string"
448
+ };
449
+ const value = {
450
+ title: "value",
451
+ type: "string"
452
+ };
453
+ const secured = {
454
+ title: "secured",
455
+ type: "boolean"
456
+ };
457
+ const token = {
458
+ title: "Authentication Token",
459
+ type: "string",
460
+ description: "The token to use for authorization to BitBucket Cloud"
461
+ };
462
+ const destination_commit = {
463
+ title: "destination_commit",
464
+ type: "object",
465
+ properties: {
466
+ hash
467
+ }
468
+ };
469
+ const commit = {
470
+ title: "commit",
471
+ type: "object",
472
+ properties: {
473
+ type,
474
+ hash
475
+ }
476
+ };
477
+ const selector = {
478
+ title: "selector",
479
+ type: "object",
480
+ properties: {
481
+ type,
482
+ pattern
483
+ }
484
+ };
485
+ const pull_request = {
486
+ title: "pull_request",
487
+ type: "object",
488
+ properties: {
489
+ id: id$1
490
+ }
491
+ };
492
+ const pipelinesRunBody = {
493
+ title: "Request Body",
494
+ description: "Request body properties: see Bitbucket Cloud Rest API documentation for more details",
495
+ type: "object",
496
+ properties: {
497
+ target: {
498
+ title: "target",
499
+ type: "object",
500
+ properties: {
501
+ ref_type,
502
+ type,
503
+ ref_name,
504
+ source,
505
+ destination,
506
+ destination_commit,
507
+ commit,
508
+ selector,
509
+ pull_request
510
+ }
511
+ },
512
+ variables: {
513
+ title: "variables",
514
+ type: "array",
515
+ items: {
516
+ type: "object",
517
+ properties: {
518
+ key,
519
+ value,
520
+ secured
521
+ }
522
+ }
523
+ }
524
+ }
525
+ };
526
+
527
+ const id = "bitbucket:pipelines:run";
528
+ const createBitbucketPipelinesRunAction = (options) => {
529
+ const { integrations } = options;
530
+ return pluginScaffolderNode.createTemplateAction({
531
+ id,
532
+ description: "Run a bitbucket cloud pipeline",
533
+ examples,
534
+ schema: {
535
+ input: {
536
+ type: "object",
537
+ required: ["workspace", "repo_slug"],
538
+ properties: {
539
+ workspace: workspace,
540
+ repo_slug: repo_slug,
541
+ body: pipelinesRunBody,
542
+ token: token
543
+ }
544
+ },
545
+ output: {
546
+ type: "object",
547
+ properties: {
548
+ buildNumber: {
549
+ title: "Build number",
550
+ type: "number"
551
+ },
552
+ repoUrl: {
553
+ title: "A URL to the pipeline repositry",
554
+ type: "string"
555
+ },
556
+ repoContentsUrl: {
557
+ title: "A URL to the pipeline",
558
+ type: "string"
559
+ }
560
+ }
561
+ }
562
+ },
563
+ supportsDryRun: false,
564
+ async handler(ctx) {
565
+ var _a;
566
+ const { workspace, repo_slug, body, token } = ctx.input;
567
+ const host = "bitbucket.org";
568
+ const integrationConfig = integrations.bitbucketCloud.byHost(host);
569
+ const authorization = getAuthorizationHeader(
570
+ token ? { token } : integrationConfig.config
571
+ );
572
+ let response;
573
+ try {
574
+ response = await fetch__default["default"](
575
+ `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/pipelines`,
576
+ {
577
+ method: "POST",
578
+ headers: {
579
+ Authorization: authorization,
580
+ Accept: "application/json",
581
+ "Content-Type": "application/json"
582
+ },
583
+ body: (_a = JSON.stringify(body)) != null ? _a : {}
584
+ }
585
+ );
586
+ } catch (e) {
587
+ throw new Error(`Unable to run pipeline, ${e}`);
588
+ }
589
+ if (response.status !== 201) {
590
+ throw new Error(
591
+ `Unable to run pipeline, ${response.status} ${response.statusText}, ${await response.text()}`
592
+ );
593
+ }
594
+ const responseObject = await response.json();
595
+ ctx.output("buildNumber", responseObject.build_number);
596
+ ctx.output("repoUrl", responseObject.repository.links.html.href);
597
+ ctx.output(
598
+ "pipelinesUrl",
599
+ `${responseObject.repository.links.html.href}/pipelines`
600
+ );
601
+ }
602
+ });
603
+ };
604
+
605
+ const bitbucketCloudModule = backendPluginApi.createBackendModule({
606
+ moduleId: "bitbucketCloud",
607
+ pluginId: "scaffolder",
608
+ register({ registerInit }) {
609
+ registerInit({
610
+ deps: {
611
+ scaffolder: alpha.scaffolderActionsExtensionPoint,
612
+ config: backendPluginApi.coreServices.rootConfig
613
+ },
614
+ async init({ scaffolder, config }) {
615
+ const integrations = integration.ScmIntegrations.fromConfig(config);
616
+ scaffolder.addActions(
617
+ createPublishBitbucketCloudAction({ integrations, config }),
618
+ createBitbucketPipelinesRunAction({ integrations })
619
+ );
620
+ }
621
+ });
622
+ }
623
+ });
624
+
625
+ exports.createBitbucketPipelinesRunAction = createBitbucketPipelinesRunAction;
626
+ exports.createPublishBitbucketCloudAction = createPublishBitbucketCloudAction;
627
+ exports["default"] = bitbucketCloudModule;
628
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/actions/helpers.ts","../src/actions/bitbucketCloud.ts","../src/actions/bitbucketCloudPipelinesRun.examples.ts","../src/actions/inputProperties.ts","../src/actions/bitbucketCloudPipelinesRun.ts","../src/module.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\nexport const getAuthorizationHeader = (config: {\n username?: string;\n appPassword?: string;\n token?: string;\n}) => {\n if (config.username && config.appPassword) {\n const buffer = Buffer.from(\n `${config.username}:${config.appPassword}`,\n 'utf8',\n );\n\n return `Basic ${buffer.toString('base64')}`;\n }\n\n if (config.token) {\n return `Bearer ${config.token}`;\n }\n\n throw new Error(\n `Authorization has not been provided for Bitbucket Cloud. Please add either username + appPassword to the Integrations config or a user login auth token`,\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 { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } 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';\n\nimport { Config } from '@backstage/config';\nimport { getAuthorizationHeader } from './helpers';\n\nconst createRepository = async (opts: {\n workspace: string;\n project: string;\n repo: string;\n description?: string;\n repoVisibility: 'private' | 'public';\n mainBranch: string;\n authorization: string;\n apiBaseUrl: string;\n}) => {\n const {\n workspace,\n project,\n repo,\n description,\n repoVisibility,\n mainBranch,\n authorization,\n apiBaseUrl,\n } = opts;\n\n const options: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n scm: 'git',\n description: description,\n is_private: repoVisibility === 'private',\n project: { key: project },\n }),\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n let response: Response;\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}`,\n options,\n );\n } catch (e) {\n throw new Error(`Unable to create repository, ${e}`);\n }\n\n if (response.status !== 200) {\n throw new Error(\n `Unable to create repository, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n const r = await response.json();\n let remoteUrl = '';\n for (const link of r.links.clone) {\n if (link.name === 'https') {\n remoteUrl = link.href;\n }\n }\n\n // \"mainbranch.name\" cannot be set neither at create nor update of the repo\n // the first pushed branch will be set as \"main branch\" then\n const repoContentsUrl = `${r.links.html.href}/src/${mainBranch}`;\n return { remoteUrl, repoContentsUrl };\n};\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to Bitbucket Cloud.\n * @public\n */\nexport function createPublishBitbucketCloudAction(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 repoVisibility?: 'private' | 'public';\n sourcePath?: string;\n token?: string;\n }>({\n id: 'publish:bitbucketCloud',\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to Bitbucket Cloud.',\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 repoVisibility: {\n title: 'Repository Visibility',\n type: 'string',\n enum: ['private', 'public'],\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 sourcePath: {\n title: 'Source Path',\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 type: 'string',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description:\n 'The token to use for authorization to BitBucket Cloud',\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 repoVisibility = 'private',\n } = ctx.input;\n\n const { workspace, project, repo, host } = parseRepoUrl(\n repoUrl,\n integrations,\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 if (!project) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing project`,\n );\n }\n\n const integrationConfig = integrations.bitbucketCloud.byHost(host);\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 authorization = getAuthorizationHeader(\n ctx.input.token ? { token: ctx.input.token } : integrationConfig.config,\n );\n\n const apiBaseUrl = integrationConfig.config.apiBaseUrl;\n\n const { remoteUrl, repoContentsUrl } = await createRepository({\n authorization,\n workspace: workspace || '',\n project,\n repo,\n repoVisibility,\n mainBranch: defaultBranch,\n description,\n apiBaseUrl,\n });\n\n const gitAuthorInfo = {\n name: config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n let auth;\n\n if (ctx.input.token) {\n auth = {\n username: 'x-token-auth',\n password: ctx.input.token,\n };\n } else {\n if (\n !integrationConfig.config.username ||\n !integrationConfig.config.appPassword\n ) {\n throw new Error(\n 'Credentials for Bitbucket Cloud integration required for this action.',\n );\n }\n\n auth = {\n username: integrationConfig.config.username,\n password: integrationConfig.config.appPassword,\n };\n }\n\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),\n remoteUrl,\n auth,\n defaultBranch,\n logger: ctx.logger,\n commitMessage: config.getOptionalString(\n 'scaffolder.defaultCommitMessage',\n ),\n gitAuthorInfo,\n });\n\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Trigger a pipeline for a branch',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n ref_type: 'branch',\n type: 'pipeline_ref_target',\n ref_name: 'master',\n },\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a pipeline for a commit on a branch',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n commit: {\n type: 'commit',\n hash: 'ce5b7431602f7cbba007062eeb55225c6e18e956',\n },\n ref_type: 'branch',\n type: 'pipeline_ref_target',\n ref_name: 'master',\n },\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a specific pipeline definition for a commit',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n commit: {\n type: 'commit',\n hash: 'a3c4e02c9a3755eccdc3764e6ea13facdf30f923',\n },\n selector: {\n type: 'custom',\n pattern: 'Deploy to production',\n },\n type: 'pipeline_commit_target',\n },\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Trigger a specific pipeline definition for a commit on a branch or tag',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n commit: {\n type: 'commit',\n hash: 'a3c4e02c9a3755eccdc3764e6ea13facdf30f923',\n },\n selector: {\n type: 'custom',\n pattern: 'Deploy to production',\n },\n type: 'pipeline_ref_target',\n ref_name: 'master',\n ref_type: 'branch',\n },\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a custom pipeline with variables',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n type: 'pipeline_ref_target',\n ref_name: 'master',\n ref_type: 'branch',\n selector: {\n type: 'custom',\n pattern: 'Deploy to production',\n },\n },\n variables: [\n { key: 'var1key', value: 'var1value', secured: true },\n {\n key: 'var2key',\n value: 'var2value',\n },\n ],\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a pull request pipeline',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n type: 'pipeline_pullrequest_target',\n source: 'pull-request-branch',\n destination: 'master',\n destination_commit: {\n hash: '9f848b7',\n },\n commit: {\n hash: '1a372fc',\n },\n pull_request: {\n id: '3',\n },\n selector: {\n type: 'pull-requests',\n pattern: '**',\n },\n },\n },\n },\n },\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\nconst workspace = {\n title: 'Workspace',\n description: `The workspace name`,\n type: 'string',\n};\n\nconst repo_slug = {\n title: 'Repository name',\n description: 'The repository name',\n type: 'string',\n};\n\nconst ref_type = {\n title: 'ref_type',\n type: 'string',\n};\n\nconst type = {\n title: 'type',\n type: 'string',\n};\n\nconst ref_name = {\n title: 'ref_name',\n type: 'string',\n};\nconst source = {\n title: 'source',\n type: 'string',\n};\nconst destination = {\n title: 'destination',\n type: 'string',\n};\nconst hash = {\n title: 'hash',\n type: 'string',\n};\n\nconst pattern = {\n title: 'pattern',\n type: 'string',\n};\n\nconst id = {\n title: 'id',\n type: 'string',\n};\n\nconst key = {\n title: 'key',\n type: 'string',\n};\nconst value = {\n title: 'value',\n type: 'string',\n};\nconst secured = {\n title: 'secured',\n type: 'boolean',\n};\n\nconst token = {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to BitBucket Cloud',\n};\n\nconst destination_commit = {\n title: 'destination_commit',\n type: 'object',\n properties: {\n hash,\n },\n};\n\nconst commit = {\n title: 'commit',\n type: 'object',\n properties: {\n type,\n hash,\n },\n};\n\nconst selector = {\n title: 'selector',\n type: 'object',\n properties: {\n type,\n pattern,\n },\n};\n\nconst pull_request = {\n title: 'pull_request',\n type: 'object',\n properties: {\n id,\n },\n};\n\nconst pipelinesRunBody = {\n title: 'Request Body',\n description:\n 'Request body properties: see Bitbucket Cloud Rest API documentation for more details',\n type: 'object',\n properties: {\n target: {\n title: 'target',\n type: 'object',\n properties: {\n ref_type,\n type,\n ref_name,\n source,\n destination,\n destination_commit,\n commit,\n selector,\n pull_request,\n },\n },\n variables: {\n title: 'variables',\n type: 'array',\n items: {\n type: 'object',\n properties: {\n key,\n value,\n secured,\n },\n },\n },\n },\n};\n\nexport { workspace, repo_slug, pipelinesRunBody, token };\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 { examples } from './bitbucketCloudPipelinesRun.examples';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport fetch, { Response } from 'node-fetch';\nimport * as inputProps from './inputProperties';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getAuthorizationHeader } from './helpers';\n\nconst id = 'bitbucket:pipelines:run';\n/**\n * Creates a new action that triggers a run of a bitbucket pipeline\n *\n * @public\n */\nexport const createBitbucketPipelinesRunAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction<{\n workspace: string;\n repo_slug: string;\n body?: object;\n token?: string;\n }>({\n id,\n description: 'Run a bitbucket cloud pipeline',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['workspace', 'repo_slug'],\n properties: {\n workspace: inputProps.workspace,\n repo_slug: inputProps.repo_slug,\n body: inputProps.pipelinesRunBody,\n token: inputProps.token,\n },\n },\n output: {\n type: 'object',\n properties: {\n buildNumber: {\n title: 'Build number',\n type: 'number',\n },\n repoUrl: {\n title: 'A URL to the pipeline repositry',\n type: 'string',\n },\n repoContentsUrl: {\n title: 'A URL to the pipeline',\n type: 'string',\n },\n },\n },\n },\n supportsDryRun: false,\n async handler(ctx) {\n const { workspace, repo_slug, body, token } = ctx.input;\n const host = 'bitbucket.org';\n const integrationConfig = integrations.bitbucketCloud.byHost(host);\n\n const authorization = getAuthorizationHeader(\n token ? { token } : integrationConfig!.config,\n );\n let response: Response;\n try {\n response = await fetch(\n `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/pipelines`,\n {\n method: 'POST',\n headers: {\n Authorization: authorization,\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body) ?? {},\n },\n );\n } catch (e) {\n throw new Error(`Unable to run pipeline, ${e}`);\n }\n\n if (response.status !== 201) {\n throw new Error(\n `Unable to run pipeline, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n const responseObject = await response.json();\n\n ctx.output('buildNumber', responseObject.build_number);\n ctx.output('repoUrl', responseObject.repository.links.html.href);\n ctx.output(\n 'pipelinesUrl',\n `${responseObject.repository.links.html.href}/pipelines`,\n );\n },\n });\n};\n","/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport {\n createBitbucketPipelinesRunAction,\n createPublishBitbucketCloudAction,\n} from './actions';\nimport { ScmIntegrations } from '@backstage/integration';\n\n/**\n * @public\n * The Bitbucket Cloud Module for the Scaffolder Backend\n */\nexport const bitbucketCloudModule = createBackendModule({\n moduleId: 'bitbucketCloud',\n pluginId: 'scaffolder',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n config: coreServices.rootConfig,\n },\n async init({ scaffolder, config }) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n scaffolder.addActions(\n createPublishBitbucketCloudAction({ integrations, config }),\n createBitbucketPipelinesRunAction({ integrations }),\n );\n },\n });\n },\n});\n"],"names":["fetch","createTemplateAction","parseRepoUrl","InputError","initRepoAndPush","getRepoSourceDirectory","yaml","id","inputProps.workspace","inputProps.repo_slug","inputProps.pipelinesRunBody","inputProps.token","createBackendModule","scaffolderActionsExtensionPoint","coreServices","ScmIntegrations"],"mappings":";;;;;;;;;;;;;;;;;AAgBa,MAAA,sBAAA,GAAyB,CAAC,MAIjC,KAAA;AACJ,EAAI,IAAA,MAAA,CAAO,QAAY,IAAA,MAAA,CAAO,WAAa,EAAA;AACzC,IAAA,MAAM,SAAS,MAAO,CAAA,IAAA;AAAA,MACpB,CAAG,EAAA,MAAA,CAAO,QAAQ,CAAA,CAAA,EAAI,OAAO,WAAW,CAAA,CAAA;AAAA,MACxC,MAAA;AAAA,KACF,CAAA;AAEA,IAAA,OAAO,CAAS,MAAA,EAAA,MAAA,CAAO,QAAS,CAAA,QAAQ,CAAC,CAAA,CAAA,CAAA;AAAA,GAC3C;AAEA,EAAA,IAAI,OAAO,KAAO,EAAA;AAChB,IAAO,OAAA,CAAA,OAAA,EAAU,OAAO,KAAK,CAAA,CAAA,CAAA;AAAA,GAC/B;AAEA,EAAA,MAAM,IAAI,KAAA;AAAA,IACR,CAAA,uJAAA,CAAA;AAAA,GACF,CAAA;AACF,CAAA;;ACRA,MAAM,gBAAA,GAAmB,OAAO,IAS1B,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,SAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA;AAAA,IACA,cAAA;AAAA,IACA,UAAA;AAAA,IACA,aAAA;AAAA,IACA,UAAA;AAAA,GACE,GAAA,IAAA,CAAA;AAEJ,EAAA,MAAM,OAAuB,GAAA;AA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EAAA,CAAA;AAE3C,MAAI,GAAA,CAAA,MAAA,CAAO,aAAe,EAAA,cAAA,CAAe,YAAY,CAAA,CAAA;AACrD,MAAA,GAAA,CAAI,OAAO,SAAW,EAAA,cAAA,CAAe,UAAW,CAAA,KAAA,CAAM,KAAK,IAAI,CAAA,CAAA;AAC/D,MAAI,GAAA,CAAA,MAAA;AAAA,QACF,cAAA;AAAA,QACA,CAAG,EAAA,cAAA,CAAe,UAAW,CAAA,KAAA,CAAM,KAAK,IAAI,CAAA,UAAA,CAAA;AAAA,OAC9C,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH;;ACtFO,MAAM,uBAAuBY,oCAAoB,CAAA;AAAA,EACtD,QAAU,EAAA,gBAAA;AAAA,EACV,QAAU,EAAA,YAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAgB,EAAA;AACzB,IAAa,YAAA,CAAA;AAAA,MACX,IAAM,EAAA;AAAA,QACJ,UAAY,EAAAC,qCAAA;AAAA,QACZ,QAAQC,6BAAa,CAAA,UAAA;AAAA,OACvB;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,UAAA,EAAY,QAAU,EAAA;AACjC,QAAM,MAAA,YAAA,GAAeC,2BAAgB,CAAA,UAAA,CAAW,MAAM,CAAA,CAAA;AAEtD,QAAW,UAAA,CAAA,UAAA;AAAA,UACT,iCAAkC,CAAA,EAAE,YAAc,EAAA,MAAA,EAAQ,CAAA;AAAA,UAC1D,iCAAA,CAAkC,EAAE,YAAA,EAAc,CAAA;AAAA,SACpD,CAAA;AAAA,OACF;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;;"}
@@ -0,0 +1,44 @@
1
+ import * as _backstage_plugin_scaffolder_node from '@backstage/plugin-scaffolder-node';
2
+ import * as _backstage_types from '@backstage/types';
3
+ import { ScmIntegrationRegistry } from '@backstage/integration';
4
+ import { Config } from '@backstage/config';
5
+ import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
6
+
7
+ /**
8
+ * Creates a new action that initializes a git repository of the content in the workspace
9
+ * and publishes it to Bitbucket Cloud.
10
+ * @public
11
+ */
12
+ declare function createPublishBitbucketCloudAction(options: {
13
+ integrations: ScmIntegrationRegistry;
14
+ config: Config;
15
+ }): _backstage_plugin_scaffolder_node.TemplateAction<{
16
+ repoUrl: string;
17
+ description?: string | undefined;
18
+ defaultBranch?: string | undefined;
19
+ repoVisibility?: "private" | "public" | undefined;
20
+ sourcePath?: string | undefined;
21
+ token?: string | undefined;
22
+ }, _backstage_types.JsonObject>;
23
+
24
+ /**
25
+ * Creates a new action that triggers a run of a bitbucket pipeline
26
+ *
27
+ * @public
28
+ */
29
+ declare const createBitbucketPipelinesRunAction: (options: {
30
+ integrations: ScmIntegrationRegistry;
31
+ }) => _backstage_plugin_scaffolder_node.TemplateAction<{
32
+ workspace: string;
33
+ repo_slug: string;
34
+ body?: object | undefined;
35
+ token?: string | undefined;
36
+ }, _backstage_types.JsonObject>;
37
+
38
+ /**
39
+ * @public
40
+ * The Bitbucket Cloud Module for the Scaffolder Backend
41
+ */
42
+ declare const bitbucketCloudModule: () => _backstage_backend_plugin_api.BackendFeature;
43
+
44
+ export { createBitbucketPipelinesRunAction, createPublishBitbucketCloudAction, bitbucketCloudModule as default };
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@backstage/plugin-scaffolder-backend-module-bitbucket-cloud",
3
+ "description": "The Bitbucket Cloud 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
+ },
11
+ "backstage": {
12
+ "role": "backend-plugin-module"
13
+ },
14
+ "exports": {
15
+ ".": {
16
+ "require": "./dist/index.cjs.js",
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.cjs.js"
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
22
+ "scripts": {
23
+ "start": "backstage-cli package start",
24
+ "build": "backstage-cli package build",
25
+ "lint": "backstage-cli package lint",
26
+ "test": "backstage-cli package test",
27
+ "clean": "backstage-cli package clean",
28
+ "prepack": "backstage-cli package prepack",
29
+ "postpack": "backstage-cli package postpack"
30
+ },
31
+ "dependencies": {
32
+ "@backstage/backend-common": "^0.21.0-next.2",
33
+ "@backstage/backend-plugin-api": "^0.6.10-next.2",
34
+ "@backstage/config": "^1.1.1",
35
+ "@backstage/errors": "^1.2.3",
36
+ "@backstage/integration": "^1.9.0-next.0",
37
+ "@backstage/plugin-scaffolder-node": "^0.3.0-next.2",
38
+ "fs-extra": "10.1.0",
39
+ "node-fetch": "^2.6.7",
40
+ "yaml": "^2.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "@backstage/backend-test-utils": "^0.3.0-next.2",
44
+ "@backstage/cli": "^0.25.2-next.2",
45
+ "msw": "^1.0.0"
46
+ },
47
+ "files": [
48
+ "dist"
49
+ ]
50
+ }