Skip to content

Commit fa7c81e

Browse files
author
Dmitry Bakhtiyarov
committed
tiny refactoring related to packages update
1 parent abbb000 commit fa7c81e

File tree

5 files changed

+4480
-3870
lines changed

5 files changed

+4480
-3870
lines changed

package.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@parfuemerie-douglas/scaffolder-backend-module-azure-pipelines",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "A collection of Backstage scaffolder backend modules for Azure pipelines.",
55
"main": "dist/index.cjs.js",
66
"types": "dist/index.d.ts",
@@ -10,7 +10,9 @@
1010
"types": "dist/index.d.ts"
1111
},
1212
"backstage": {
13-
"role": "backend-plugin-module"
13+
"role": "backend-plugin-module",
14+
"pluginId": "scaffolder",
15+
"pluginPackage": "@backstage/plugin-scaffolder-backend"
1416
},
1517
"scripts": {
1618
"start": "backstage-cli package start",
@@ -39,16 +41,16 @@
3941
},
4042
"homepage": "https://github.com/Parfuemerie-Douglas/scaffolder-backend-module-azure-pipelines#readme",
4143
"dependencies": {
42-
"@backstage/backend-common": "^0.20.0",
43-
"@backstage/errors": "^1.2.3",
44-
"@backstage/integration": "^1.8.0",
45-
"@backstage/plugin-scaffolder-backend": "^1.19.2",
46-
"@backstage/plugin-scaffolder-node": "^0.2.9",
44+
"@backstage/backend-common": "^0.23.3",
45+
"@backstage/errors": "^1.2.4",
46+
"@backstage/integration": "^1.13.0",
47+
"@backstage/plugin-scaffolder-backend": "^1.23.0",
48+
"@backstage/plugin-scaffolder-node": "^0.4.8",
4749
"@backstage/types": "^1.1.1",
48-
"node-fetch": "^2.6.2"
50+
"node-fetch": "^3.3.2"
4951
},
5052
"devDependencies": {
51-
"@backstage/cli": "^0.25.1",
53+
"@backstage/cli": "^0.26.11",
5254
"@types/node-fetch": "^2.6.2"
5355
},
5456
"dependenciesMeta": {

src/actions/run/createAzurePipeline.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import { DefaultAzureDevOpsCredentialsProvider, ScmIntegrationRegistry } from "@backstage/integration";
1818
import { createTemplateAction } from "@backstage/plugin-scaffolder-node";
1919

20-
import fetch from "node-fetch";
21-
2220
export const createAzurePipelineAction = (options: {
2321
integrations: ScmIntegrationRegistry;
2422
}) => {
@@ -54,11 +52,6 @@ export const createAzurePipelineAction = (options: {
5452
title: "Create API version",
5553
description: "The Azure Create Pipeline API version to use. Defaults to 6.1-preview.1",
5654
},
57-
server: {
58-
type: "string",
59-
title: "Host",
60-
description: "The host of Azure DevOps. Defaults to dev.azure.com",
61-
},
6255
organization: {
6356
type: "string",
6457
title: "Organization",
@@ -121,6 +114,8 @@ export const createAzurePipelineAction = (options: {
121114
`Creating an Azure pipeline for the repository ${repositoryName} with the ID ${repositoryId}.`
122115
);
123116

117+
const fetchModule = await import("node-fetch");
118+
const fetch: typeof fetchModule.default = fetchModule.default;
124119
// See the Azure DevOps documentation for more information about the REST API:
125120
// https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/pipelines/create?view=azure-devops-rest-6.1
126121
await fetch(
@@ -150,7 +145,7 @@ export const createAzurePipelineAction = (options: {
150145
}),
151146
}
152147
)
153-
.then((response) => {
148+
.then((response: any) => {
154149
if (response.ok) {
155150
ctx.logger.info(
156151
`Successfully created ${name} Azure pipeline in ${folder}.`
@@ -163,7 +158,7 @@ export const createAzurePipelineAction = (options: {
163158

164159
return response.json();
165160
})
166-
.then((data) => {
161+
.then((data: any) => {
167162
ctx.logger.info(`The Azure pipeline ID is ${data.id}.`);
168163

169164
ctx.output("pipelineId", data.id.toString());

src/actions/run/permitAzurePipeline.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import { DefaultAzureDevOpsCredentialsProvider, ScmIntegrationRegistry } from "@backstage/integration";
1818
import { createTemplateAction } from "@backstage/plugin-scaffolder-node";
1919

20-
import fetch from "node-fetch";
21-
2220
export const permitAzurePipelineAction = (options: {
2321
integrations: ScmIntegrationRegistry;
2422
}) => {
@@ -53,11 +51,6 @@ export const permitAzurePipelineAction = (options: {
5351
title: "Permits API version",
5452
description: "The Azure Permits Pipeline API version to use. Defaults to 7.1-preview.1",
5553
},
56-
server: {
57-
type: "string",
58-
title: "Host",
59-
description: "The host of Azure DevOps. Defaults to dev.azure.com",
60-
},
6154
organization: {
6255
type: "string",
6356
title: "Organization",
@@ -120,6 +113,8 @@ export const permitAzurePipelineAction = (options: {
120113
);
121114
}
122115

116+
const fetchModule = await import("node-fetch");
117+
const fetch: typeof fetchModule.default = fetchModule.default;
123118
// See the Azure DevOps documentation for more information about the REST API:
124119
// https://docs.microsoft.com/en-us/rest/api/azure/devops/approvalsandchecks/pipeline-permissions/update-pipeline-permisions-for-resource?view=azure-devops-rest-7.1
125120
await fetch(
@@ -143,7 +138,7 @@ export const permitAzurePipelineAction = (options: {
143138
],
144139
}),
145140
}
146-
).then((response) => {
141+
).then((response: any) => {
147142
if (response.ok) {
148143
ctx.logger.info(
149144
`Successfully changed the Azure pipeline permissions.`

src/actions/run/runAzurePipeline.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import { DefaultAzureDevOpsCredentialsProvider, ScmIntegrationRegistry } from "@backstage/integration";
1818
import { createTemplateAction } from "@backstage/plugin-scaffolder-node";
1919

20-
import fetch from "node-fetch";
21-
2220
interface RunPipelineRequest {
2321
previewRun?: boolean;
2422
resources?: {
@@ -60,7 +58,7 @@ export const runAzurePipelineAction = (options: {
6058
if (!response.ok) {
6159
throw new Error(`Failed to retrieve pipeline run status. Status code ${response.status}.`);
6260
}
63-
const json = await response.json();
61+
const json: any = await response.json();
6462
const status = json.status;
6563
if (status === "completed") {
6664
return json.result === "succeeded";
@@ -104,11 +102,6 @@ export const runAzurePipelineAction = (options: {
104102
title: "Build API version",
105103
description: "The Builds API version to use. Defaults to 6.1-preview.6",
106104
},
107-
server: {
108-
type: "string",
109-
title: "Host",
110-
description: "The host of Azure DevOps. Defaults to dev.azure.com",
111-
},
112105
organization: {
113106
type: "string",
114107
title: "Organization",
@@ -175,6 +168,9 @@ export const runAzurePipelineAction = (options: {
175168

176169
const body = JSON.stringify(request);
177170

171+
172+
const fetchModule = await import("node-fetch");
173+
const fetch: typeof fetchModule.default = fetchModule.default;
178174
// See the Azure DevOps documentation for more information about the REST API:
179175
// https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/run-pipeline?view=azure-devops-rest-7.0
180176
await fetch(
@@ -191,12 +187,12 @@ export const runAzurePipelineAction = (options: {
191187
},
192188
body,
193189
}
194-
).then((response) => {
190+
).then((response: any) => {
195191
if (response.ok) {
196192
return response.json();
197193
}
198194
throw new Error(`Failed to run Azure pipeline. Status code ${response.status}.`);
199-
}).then((json) => {
195+
}).then((json: any) => {
200196
const pipelineUrl = json._links.web.href;
201197
ctx.logger.info(`Successfully started Azure pipeline run: ${pipelineUrl}`);
202198

@@ -205,14 +201,14 @@ export const runAzurePipelineAction = (options: {
205201
// Poll the pipeline status until it completes.
206202
return checkPipelineStatus(host, organization, project, pipelineRunId, token, apiVersions.buildApiVersion);
207203
})
208-
.then((success) => {
204+
.then((success: any) => {
209205
if (success) {
210206
ctx.logger.info(`Azure pipeline completed successfully.`);
211207
} else {
212208
ctx.logger.error(`Azure pipeline failed.`);
213209
}
214210
})
215-
.catch((error) => {
211+
.catch((error: any) => {
216212
// Handle any errors that occurred during the pipeline run or status check.
217213
ctx.logger.error(error.message);
218214
});

0 commit comments

Comments
 (0)