@backstage/plugin-scaffolder-backend-module-azure 0.2.1-next.1 → 0.2.1

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,29 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-azure
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - b06aa48: Updated dependency `azure-devops-node-api` to `^14.0.0`.
8
+ - Updated dependencies
9
+ - @backstage/plugin-scaffolder-node@0.5.0
10
+ - @backstage/integration@1.15.1
11
+ - @backstage/backend-plugin-api@1.0.1
12
+ - @backstage/config@1.2.0
13
+ - @backstage/errors@1.2.4
14
+
15
+ ## 0.2.1-next.2
16
+
17
+ ### Patch Changes
18
+
19
+ - b06aa48: Updated dependency `azure-devops-node-api` to `^14.0.0`.
20
+ - Updated dependencies
21
+ - @backstage/integration@1.15.1-next.1
22
+ - @backstage/plugin-scaffolder-node@0.5.0-next.2
23
+ - @backstage/backend-plugin-api@1.0.1-next.1
24
+ - @backstage/config@1.2.0
25
+ - @backstage/errors@1.2.4
26
+
3
27
  ## 0.2.1-next.1
4
28
 
5
29
  ### Patch Changes
@@ -0,0 +1,163 @@
1
+ 'use strict';
2
+
3
+ var errors = require('@backstage/errors');
4
+ var integration = require('@backstage/integration');
5
+ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
6
+ var azureDevopsNodeApi = require('azure-devops-node-api');
7
+ var azure_examples = require('./azure.examples.cjs.js');
8
+
9
+ function createPublishAzureAction(options) {
10
+ const { integrations, config } = options;
11
+ return pluginScaffolderNode.createTemplateAction({
12
+ id: "publish:azure",
13
+ examples: azure_examples.examples,
14
+ description: "Initializes a git repository of the content in the workspace, and publishes it to Azure.",
15
+ schema: {
16
+ input: {
17
+ type: "object",
18
+ required: ["repoUrl"],
19
+ properties: {
20
+ repoUrl: {
21
+ title: "Repository Location",
22
+ type: "string"
23
+ },
24
+ description: {
25
+ title: "Repository Description",
26
+ type: "string"
27
+ },
28
+ defaultBranch: {
29
+ title: "Default Branch",
30
+ type: "string",
31
+ description: `Sets the default branch on the repository. The default value is 'master'`
32
+ },
33
+ gitCommitMessage: {
34
+ title: "Git Commit Message",
35
+ type: "string",
36
+ description: `Sets the commit message on the repository. The default value is 'initial commit'`
37
+ },
38
+ gitAuthorName: {
39
+ title: "Default Author Name",
40
+ type: "string",
41
+ description: `Sets the default author name for the commit. The default value is 'Scaffolder'`
42
+ },
43
+ gitAuthorEmail: {
44
+ title: "Default Author Email",
45
+ type: "string",
46
+ description: `Sets the default author email for the commit.`
47
+ },
48
+ sourcePath: {
49
+ title: "Source Path",
50
+ description: "Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.",
51
+ type: "string"
52
+ },
53
+ token: {
54
+ title: "Authentication Token",
55
+ type: "string",
56
+ description: "The token to use for authorization to Azure"
57
+ }
58
+ }
59
+ },
60
+ output: {
61
+ type: "object",
62
+ properties: {
63
+ remoteUrl: {
64
+ title: "A URL to the repository with the provider",
65
+ type: "string"
66
+ },
67
+ repoContentsUrl: {
68
+ title: "A URL to the root of the repository",
69
+ type: "string"
70
+ },
71
+ repositoryId: {
72
+ title: "The Id of the created repository",
73
+ type: "string"
74
+ },
75
+ commitHash: {
76
+ title: "The git commit hash of the initial commit",
77
+ type: "string"
78
+ }
79
+ }
80
+ }
81
+ },
82
+ async handler(ctx) {
83
+ const {
84
+ repoUrl,
85
+ defaultBranch = "master",
86
+ gitCommitMessage = "initial commit",
87
+ gitAuthorName,
88
+ gitAuthorEmail
89
+ } = ctx.input;
90
+ const { project, repo, host, organization } = pluginScaffolderNode.parseRepoUrl(
91
+ repoUrl,
92
+ integrations
93
+ );
94
+ if (!organization) {
95
+ throw new errors.InputError(
96
+ `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing organization`
97
+ );
98
+ }
99
+ const url = `https://${host}/${organization}`;
100
+ const credentialProvider = integration.DefaultAzureDevOpsCredentialsProvider.fromIntegrations(integrations);
101
+ const credentials = await credentialProvider.getCredentials({ url });
102
+ if (credentials === void 0 && ctx.input.token === void 0) {
103
+ throw new errors.InputError(
104
+ `No credentials provided ${url}, please check your integrations config`
105
+ );
106
+ }
107
+ const authHandler = ctx.input.token || credentials?.type === "pat" ? azureDevopsNodeApi.getPersonalAccessTokenHandler(ctx.input.token ?? credentials.token) : azureDevopsNodeApi.getBearerHandler(credentials.token);
108
+ const webApi = new azureDevopsNodeApi.WebApi(url, authHandler);
109
+ const client = await webApi.getGitApi();
110
+ const createOptions = { name: repo };
111
+ const returnedRepo = await client.createRepository(
112
+ createOptions,
113
+ project
114
+ );
115
+ if (!returnedRepo) {
116
+ throw new errors.InputError(
117
+ `Unable to create the repository with Organization ${organization}, Project ${project} and Repo ${repo}.
118
+ Please make sure that both the Org and Project are typed corrected and exist.`
119
+ );
120
+ }
121
+ const remoteUrl = returnedRepo.remoteUrl;
122
+ if (!remoteUrl) {
123
+ throw new errors.InputError(
124
+ "No remote URL returned from create repository for Azure"
125
+ );
126
+ }
127
+ const repositoryId = returnedRepo.id;
128
+ if (!repositoryId) {
129
+ throw new errors.InputError("No Id returned from create repository for Azure");
130
+ }
131
+ const repoContentsUrl = returnedRepo.webUrl;
132
+ if (!repoContentsUrl) {
133
+ throw new errors.InputError(
134
+ "No web URL returned from create repository for Azure"
135
+ );
136
+ }
137
+ const gitAuthorInfo = {
138
+ name: gitAuthorName ? gitAuthorName : config.getOptionalString("scaffolder.defaultAuthor.name"),
139
+ email: gitAuthorEmail ? gitAuthorEmail : config.getOptionalString("scaffolder.defaultAuthor.email")
140
+ };
141
+ const auth = {
142
+ username: "notempty",
143
+ password: ctx.input.token ?? credentials.token
144
+ };
145
+ const commitResult = await pluginScaffolderNode.initRepoAndPush({
146
+ dir: pluginScaffolderNode.getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),
147
+ remoteUrl,
148
+ defaultBranch,
149
+ auth,
150
+ logger: ctx.logger,
151
+ commitMessage: gitCommitMessage ? gitCommitMessage : config.getOptionalString("scaffolder.defaultCommitMessage"),
152
+ gitAuthorInfo
153
+ });
154
+ ctx.output("commitHash", commitResult?.commitHash);
155
+ ctx.output("remoteUrl", remoteUrl);
156
+ ctx.output("repoContentsUrl", repoContentsUrl);
157
+ ctx.output("repositoryId", repositoryId);
158
+ }
159
+ });
160
+ }
161
+
162
+ exports.createPublishAzureAction = createPublishAzureAction;
163
+ //# sourceMappingURL=azure.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azure.cjs.js","sources":["../../src/actions/azure.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 DefaultAzureDevOpsCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n initRepoAndPush,\n getRepoSourceDirectory,\n parseRepoUrl,\n createTemplateAction,\n} from '@backstage/plugin-scaffolder-node';\nimport { GitRepositoryCreateOptions } from 'azure-devops-node-api/interfaces/GitInterfaces';\nimport {\n getBearerHandler,\n getPersonalAccessTokenHandler,\n WebApi,\n} from 'azure-devops-node-api';\nimport { Config } from '@backstage/config';\nimport { examples } from './azure.examples';\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to Azure.\n * @public\n */\nexport function createPublishAzureAction(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 sourcePath?: string;\n token?: string;\n gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n }>({\n id: 'publish:azure',\n examples,\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to Azure.',\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 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: 'The token to use for authorization to Azure',\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 repositoryId: {\n title: 'The Id of the created 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 defaultBranch = 'master',\n gitCommitMessage = 'initial commit',\n gitAuthorName,\n gitAuthorEmail,\n } = ctx.input;\n\n const { project, repo, host, organization } = parseRepoUrl(\n repoUrl,\n integrations,\n );\n\n if (!organization) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing organization`,\n );\n }\n\n const url = `https://${host}/${organization}`;\n const credentialProvider =\n DefaultAzureDevOpsCredentialsProvider.fromIntegrations(integrations);\n const credentials = await credentialProvider.getCredentials({ url: url });\n\n if (credentials === undefined && ctx.input.token === undefined) {\n throw new InputError(\n `No credentials provided ${url}, please check your integrations config`,\n );\n }\n\n const authHandler =\n ctx.input.token || credentials?.type === 'pat'\n ? getPersonalAccessTokenHandler(ctx.input.token ?? credentials!.token)\n : getBearerHandler(credentials!.token);\n\n const webApi = new WebApi(url, authHandler);\n const client = await webApi.getGitApi();\n const createOptions: GitRepositoryCreateOptions = { name: repo };\n const returnedRepo = await client.createRepository(\n createOptions,\n project,\n );\n\n if (!returnedRepo) {\n throw new InputError(\n `Unable to create the repository with Organization ${organization}, Project ${project} and Repo ${repo}.\n Please make sure that both the Org and Project are typed corrected and exist.`,\n );\n }\n const remoteUrl = returnedRepo.remoteUrl;\n\n if (!remoteUrl) {\n throw new InputError(\n 'No remote URL returned from create repository for Azure',\n );\n }\n const repositoryId = returnedRepo.id;\n\n if (!repositoryId) {\n throw new InputError('No Id returned from create repository for Azure');\n }\n\n const repoContentsUrl = returnedRepo.webUrl;\n\n if (!repoContentsUrl) {\n throw new InputError(\n 'No web URL returned from create repository for Azure',\n );\n }\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 auth = {\n username: 'notempty',\n password: ctx.input.token ?? credentials!.token,\n };\n\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),\n remoteUrl,\n defaultBranch,\n auth: auth,\n logger: ctx.logger,\n commitMessage: gitCommitMessage\n ? gitCommitMessage\n : config.getOptionalString('scaffolder.defaultCommitMessage'),\n gitAuthorInfo,\n });\n\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n ctx.output('repositoryId', repositoryId);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","DefaultAzureDevOpsCredentialsProvider","getPersonalAccessTokenHandler","getBearerHandler","WebApi","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;;;AAyCO,SAAS,yBAAyB,OAGtC,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,MAAA,EAAW,GAAA,OAAA,CAAA;AAEjC,EAAA,OAAOA,yCASJ,CAAA;AAAA,IACD,EAAI,EAAA,eAAA;AAAA,cACJC,uBAAA;AAAA,IACA,WACE,EAAA,0FAAA;AAAA,IACF,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,SAAS,CAAA;AAAA,QACpB,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,UACA,WAAa,EAAA;AAAA,YACX,KAAO,EAAA,wBAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,UACA,aAAe,EAAA;AAAA,YACb,KAAO,EAAA,gBAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,YACN,WAAa,EAAA,CAAA,wEAAA,CAAA;AAAA,WACf;AAAA,UACA,gBAAkB,EAAA;AAAA,YAChB,KAAO,EAAA,oBAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,YACN,WAAa,EAAA,CAAA,gFAAA,CAAA;AAAA,WACf;AAAA,UACA,aAAe,EAAA;AAAA,YACb,KAAO,EAAA,qBAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,YACN,WAAa,EAAA,CAAA,8EAAA,CAAA;AAAA,WACf;AAAA,UACA,cAAgB,EAAA;AAAA,YACd,KAAO,EAAA,sBAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,YACN,WAAa,EAAA,CAAA,6CAAA,CAAA;AAAA,WACf;AAAA,UACA,UAAY,EAAA;AAAA,YACV,KAA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I,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA,CAAA;AAC7C,MAAI,GAAA,CAAA,MAAA,CAAO,gBAAgB,YAAY,CAAA,CAAA;AAAA,KACzC;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
@@ -0,0 +1,140 @@
1
+ 'use strict';
2
+
3
+ var yaml = require('yaml');
4
+
5
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
6
+
7
+ var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
8
+
9
+ const examples = [
10
+ {
11
+ description: "Initializes a git repository with the content in the workspace, and publishes it to Azure DevOps with the default configuration.",
12
+ example: yaml__default.default.stringify({
13
+ steps: [
14
+ {
15
+ id: "publish",
16
+ action: "publish:azure",
17
+ name: "Publish to Azure",
18
+ input: {
19
+ repoUrl: "dev.azure.com?organization=organization&project=project&repo=repo"
20
+ }
21
+ }
22
+ ]
23
+ })
24
+ },
25
+ {
26
+ description: "Initializes an Azure DevOps repository with a description.",
27
+ example: yaml__default.default.stringify({
28
+ steps: [
29
+ {
30
+ id: "publish",
31
+ action: "publish:azure",
32
+ name: "Publish to Azure",
33
+ input: {
34
+ repoUrl: "dev.azure.com?organization=organization&project=project&repo=repo",
35
+ description: "Initialize a git repository"
36
+ }
37
+ }
38
+ ]
39
+ })
40
+ },
41
+ {
42
+ description: "Initializes an Azure DevOps repository with a default branch, if not set defaults to master",
43
+ example: yaml__default.default.stringify({
44
+ steps: [
45
+ {
46
+ id: "publish",
47
+ action: "publish:azure",
48
+ name: "Publish to Azure",
49
+ input: {
50
+ repoUrl: "dev.azure.com?organization=organization&project=project&repo=repo",
51
+ defaultBranch: "main"
52
+ }
53
+ }
54
+ ]
55
+ })
56
+ },
57
+ {
58
+ description: "Initializes an Azure DevOps repository with a custom commit message",
59
+ example: yaml__default.default.stringify({
60
+ steps: [
61
+ {
62
+ id: "publish",
63
+ action: "publish:azure",
64
+ name: "Publish to Azure",
65
+ input: {
66
+ repoUrl: "dev.azure.com?organization=organization&project=project&repo=repo",
67
+ gitCommitMessage: "Initial setup and configuration"
68
+ }
69
+ }
70
+ ]
71
+ })
72
+ },
73
+ {
74
+ description: "Initializes an Azure DevOps repository with a custom author name and email",
75
+ example: yaml__default.default.stringify({
76
+ steps: [
77
+ {
78
+ id: "publish",
79
+ action: "publish:azure",
80
+ name: "Publish to Azure",
81
+ input: {
82
+ repoUrl: "dev.azure.com?organization=organization&project=project&repo=repo",
83
+ gitAuthorName: "John Doe",
84
+ gitAuthorEmail: "john.doe@example.com"
85
+ }
86
+ }
87
+ ]
88
+ })
89
+ },
90
+ {
91
+ description: "Initializes an Azure DevOps repository using a specific source path",
92
+ example: yaml__default.default.stringify({
93
+ steps: [
94
+ {
95
+ id: "publish",
96
+ action: "publish:azure",
97
+ name: "Publish to Azure",
98
+ input: {
99
+ repoUrl: "dev.azure.com?organization=organization&project=project&repo=repo",
100
+ sourcePath: "path/to/source"
101
+ }
102
+ }
103
+ ]
104
+ })
105
+ },
106
+ {
107
+ description: "Initializes an Azure DevOps repository using an authentication token",
108
+ example: yaml__default.default.stringify({
109
+ steps: [
110
+ {
111
+ id: "publish",
112
+ action: "publish:azure",
113
+ name: "Publish to Azure",
114
+ input: {
115
+ repoUrl: "dev.azure.com?organization=organization&project=project&repo=repo",
116
+ token: "personal-access-token"
117
+ }
118
+ }
119
+ ]
120
+ })
121
+ },
122
+ {
123
+ description: "Initializes an Azure DevOps repository using an custom repo url",
124
+ example: yaml__default.default.stringify({
125
+ steps: [
126
+ {
127
+ id: "publish",
128
+ action: "publish:azure",
129
+ name: "Publish to Azure",
130
+ input: {
131
+ repoUrl: "test.azure.com?organization=organization&project=project&repo=repo"
132
+ }
133
+ }
134
+ ]
135
+ })
136
+ }
137
+ ];
138
+
139
+ exports.examples = examples;
140
+ //# sourceMappingURL=azure.examples.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azure.examples.cjs.js","sources":["../../src/actions/azure.examples.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 git repository with the content in the workspace, and publishes it to Azure DevOps with the default configuration.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:azure',\n name: 'Publish to Azure',\n input: {\n repoUrl:\n 'dev.azure.com?organization=organization&project=project&repo=repo',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes an Azure DevOps repository with a description.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:azure',\n name: 'Publish to Azure',\n input: {\n repoUrl:\n 'dev.azure.com?organization=organization&project=project&repo=repo',\n description: 'Initialize a git repository',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes an Azure DevOps repository with a default branch, if not set defaults to master',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:azure',\n name: 'Publish to Azure',\n input: {\n repoUrl:\n 'dev.azure.com?organization=organization&project=project&repo=repo',\n defaultBranch: 'main',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes an Azure DevOps repository with a custom commit message',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:azure',\n name: 'Publish to Azure',\n input: {\n repoUrl:\n 'dev.azure.com?organization=organization&project=project&repo=repo',\n gitCommitMessage: 'Initial setup and configuration',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes an Azure DevOps repository with a custom author name and email',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:azure',\n name: 'Publish to Azure',\n input: {\n repoUrl:\n 'dev.azure.com?organization=organization&project=project&repo=repo',\n gitAuthorName: 'John Doe',\n gitAuthorEmail: 'john.doe@example.com',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes an Azure DevOps repository using a specific source path',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:azure',\n name: 'Publish to Azure',\n input: {\n repoUrl:\n 'dev.azure.com?organization=organization&project=project&repo=repo',\n sourcePath: 'path/to/source',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes an Azure DevOps repository using an authentication token',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:azure',\n name: 'Publish to Azure',\n input: {\n repoUrl:\n 'dev.azure.com?organization=organization&project=project&repo=repo',\n token: 'personal-access-token',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes an Azure DevOps repository using an custom repo url',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:azure',\n name: 'Publish to Azure',\n input: {\n repoUrl:\n 'test.azure.com?organization=organization&project=project&repo=repo',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WACE,EAAA,kIAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,EAAA,eAAA;AAAA,UACR,IAAM,EAAA,kBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,mEAAA;AAAA,WACJ;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,4DAAA;AAAA,IACb,OAAA,EAASA,sBAA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esModule', { value: true });
4
4
 
5
- var errors = require('@backstage/errors');
6
- var integration = require('@backstage/integration');
7
- var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
8
- var azureDevopsNodeApi = require('azure-devops-node-api');
9
- var yaml = require('yaml');
10
- var backendPluginApi = require('@backstage/backend-plugin-api');
11
- var alpha = require('@backstage/plugin-scaffolder-node/alpha');
5
+ var azure = require('./actions/azure.cjs.js');
6
+ var module$1 = require('./module.cjs.js');
12
7
 
13
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
14
8
 
15
- var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
16
9
 
17
- const examples = [
18
- {
19
- description: "Initializes a git repository with the content in the workspace, and publishes it to Azure DevOps with the default configuration.",
20
- example: yaml__default.default.stringify({
21
- steps: [
22
- {
23
- id: "publish",
24
- action: "publish:azure",
25
- name: "Publish to Azure",
26
- input: {
27
- repoUrl: "dev.azure.com?organization=organization&project=project&repo=repo"
28
- }
29
- }
30
- ]
31
- })
32
- },
33
- {
34
- description: "Initializes an Azure DevOps repository with a description.",
35
- example: yaml__default.default.stringify({
36
- steps: [
37
- {
38
- id: "publish",
39
- action: "publish:azure",
40
- name: "Publish to Azure",
41
- input: {
42
- repoUrl: "dev.azure.com?organization=organization&project=project&repo=repo",
43
- description: "Initialize a git repository"
44
- }
45
- }
46
- ]
47
- })
48
- },
49
- {
50
- description: "Initializes an Azure DevOps repository with a default branch, if not set defaults to master",
51
- example: yaml__default.default.stringify({
52
- steps: [
53
- {
54
- id: "publish",
55
- action: "publish:azure",
56
- name: "Publish to Azure",
57
- input: {
58
- repoUrl: "dev.azure.com?organization=organization&project=project&repo=repo",
59
- defaultBranch: "main"
60
- }
61
- }
62
- ]
63
- })
64
- },
65
- {
66
- description: "Initializes an Azure DevOps repository with a custom commit message",
67
- example: yaml__default.default.stringify({
68
- steps: [
69
- {
70
- id: "publish",
71
- action: "publish:azure",
72
- name: "Publish to Azure",
73
- input: {
74
- repoUrl: "dev.azure.com?organization=organization&project=project&repo=repo",
75
- gitCommitMessage: "Initial setup and configuration"
76
- }
77
- }
78
- ]
79
- })
80
- },
81
- {
82
- description: "Initializes an Azure DevOps repository with a custom author name and email",
83
- example: yaml__default.default.stringify({
84
- steps: [
85
- {
86
- id: "publish",
87
- action: "publish:azure",
88
- name: "Publish to Azure",
89
- input: {
90
- repoUrl: "dev.azure.com?organization=organization&project=project&repo=repo",
91
- gitAuthorName: "John Doe",
92
- gitAuthorEmail: "john.doe@example.com"
93
- }
94
- }
95
- ]
96
- })
97
- },
98
- {
99
- description: "Initializes an Azure DevOps repository using a specific source path",
100
- example: yaml__default.default.stringify({
101
- steps: [
102
- {
103
- id: "publish",
104
- action: "publish:azure",
105
- name: "Publish to Azure",
106
- input: {
107
- repoUrl: "dev.azure.com?organization=organization&project=project&repo=repo",
108
- sourcePath: "path/to/source"
109
- }
110
- }
111
- ]
112
- })
113
- },
114
- {
115
- description: "Initializes an Azure DevOps repository using an authentication token",
116
- example: yaml__default.default.stringify({
117
- steps: [
118
- {
119
- id: "publish",
120
- action: "publish:azure",
121
- name: "Publish to Azure",
122
- input: {
123
- repoUrl: "dev.azure.com?organization=organization&project=project&repo=repo",
124
- token: "personal-access-token"
125
- }
126
- }
127
- ]
128
- })
129
- },
130
- {
131
- description: "Initializes an Azure DevOps repository using an custom repo url",
132
- example: yaml__default.default.stringify({
133
- steps: [
134
- {
135
- id: "publish",
136
- action: "publish:azure",
137
- name: "Publish to Azure",
138
- input: {
139
- repoUrl: "test.azure.com?organization=organization&project=project&repo=repo"
140
- }
141
- }
142
- ]
143
- })
144
- }
145
- ];
146
-
147
- function createPublishAzureAction(options) {
148
- const { integrations, config } = options;
149
- return pluginScaffolderNode.createTemplateAction({
150
- id: "publish:azure",
151
- examples,
152
- description: "Initializes a git repository of the content in the workspace, and publishes it to Azure.",
153
- schema: {
154
- input: {
155
- type: "object",
156
- required: ["repoUrl"],
157
- properties: {
158
- repoUrl: {
159
- title: "Repository Location",
160
- type: "string"
161
- },
162
- description: {
163
- title: "Repository Description",
164
- type: "string"
165
- },
166
- defaultBranch: {
167
- title: "Default Branch",
168
- type: "string",
169
- description: `Sets the default branch on the repository. The default value is 'master'`
170
- },
171
- gitCommitMessage: {
172
- title: "Git Commit Message",
173
- type: "string",
174
- description: `Sets the commit message on the repository. The default value is 'initial commit'`
175
- },
176
- gitAuthorName: {
177
- title: "Default Author Name",
178
- type: "string",
179
- description: `Sets the default author name for the commit. The default value is 'Scaffolder'`
180
- },
181
- gitAuthorEmail: {
182
- title: "Default Author Email",
183
- type: "string",
184
- description: `Sets the default author email for the commit.`
185
- },
186
- sourcePath: {
187
- title: "Source Path",
188
- description: "Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.",
189
- type: "string"
190
- },
191
- token: {
192
- title: "Authentication Token",
193
- type: "string",
194
- description: "The token to use for authorization to Azure"
195
- }
196
- }
197
- },
198
- output: {
199
- type: "object",
200
- properties: {
201
- remoteUrl: {
202
- title: "A URL to the repository with the provider",
203
- type: "string"
204
- },
205
- repoContentsUrl: {
206
- title: "A URL to the root of the repository",
207
- type: "string"
208
- },
209
- repositoryId: {
210
- title: "The Id of the created repository",
211
- type: "string"
212
- },
213
- commitHash: {
214
- title: "The git commit hash of the initial commit",
215
- type: "string"
216
- }
217
- }
218
- }
219
- },
220
- async handler(ctx) {
221
- const {
222
- repoUrl,
223
- defaultBranch = "master",
224
- gitCommitMessage = "initial commit",
225
- gitAuthorName,
226
- gitAuthorEmail
227
- } = ctx.input;
228
- const { project, repo, host, organization } = pluginScaffolderNode.parseRepoUrl(
229
- repoUrl,
230
- integrations
231
- );
232
- if (!organization) {
233
- throw new errors.InputError(
234
- `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing organization`
235
- );
236
- }
237
- const url = `https://${host}/${organization}`;
238
- const credentialProvider = integration.DefaultAzureDevOpsCredentialsProvider.fromIntegrations(integrations);
239
- const credentials = await credentialProvider.getCredentials({ url });
240
- if (credentials === void 0 && ctx.input.token === void 0) {
241
- throw new errors.InputError(
242
- `No credentials provided ${url}, please check your integrations config`
243
- );
244
- }
245
- const authHandler = ctx.input.token || credentials?.type === "pat" ? azureDevopsNodeApi.getPersonalAccessTokenHandler(ctx.input.token ?? credentials.token) : azureDevopsNodeApi.getBearerHandler(credentials.token);
246
- const webApi = new azureDevopsNodeApi.WebApi(url, authHandler);
247
- const client = await webApi.getGitApi();
248
- const createOptions = { name: repo };
249
- const returnedRepo = await client.createRepository(
250
- createOptions,
251
- project
252
- );
253
- if (!returnedRepo) {
254
- throw new errors.InputError(
255
- `Unable to create the repository with Organization ${organization}, Project ${project} and Repo ${repo}.
256
- Please make sure that both the Org and Project are typed corrected and exist.`
257
- );
258
- }
259
- const remoteUrl = returnedRepo.remoteUrl;
260
- if (!remoteUrl) {
261
- throw new errors.InputError(
262
- "No remote URL returned from create repository for Azure"
263
- );
264
- }
265
- const repositoryId = returnedRepo.id;
266
- if (!repositoryId) {
267
- throw new errors.InputError("No Id returned from create repository for Azure");
268
- }
269
- const repoContentsUrl = returnedRepo.webUrl;
270
- if (!repoContentsUrl) {
271
- throw new errors.InputError(
272
- "No web URL returned from create repository for Azure"
273
- );
274
- }
275
- const gitAuthorInfo = {
276
- name: gitAuthorName ? gitAuthorName : config.getOptionalString("scaffolder.defaultAuthor.name"),
277
- email: gitAuthorEmail ? gitAuthorEmail : config.getOptionalString("scaffolder.defaultAuthor.email")
278
- };
279
- const auth = {
280
- username: "notempty",
281
- password: ctx.input.token ?? credentials.token
282
- };
283
- const commitResult = await pluginScaffolderNode.initRepoAndPush({
284
- dir: pluginScaffolderNode.getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),
285
- remoteUrl,
286
- defaultBranch,
287
- auth,
288
- logger: ctx.logger,
289
- commitMessage: gitCommitMessage ? gitCommitMessage : config.getOptionalString("scaffolder.defaultCommitMessage"),
290
- gitAuthorInfo
291
- });
292
- ctx.output("commitHash", commitResult?.commitHash);
293
- ctx.output("remoteUrl", remoteUrl);
294
- ctx.output("repoContentsUrl", repoContentsUrl);
295
- ctx.output("repositoryId", repositoryId);
296
- }
297
- });
298
- }
299
-
300
- const azureModule = backendPluginApi.createBackendModule({
301
- moduleId: "azure",
302
- pluginId: "scaffolder",
303
- register({ registerInit }) {
304
- registerInit({
305
- deps: {
306
- scaffolderActions: alpha.scaffolderActionsExtensionPoint,
307
- config: backendPluginApi.coreServices.rootConfig
308
- },
309
- async init({ scaffolderActions, config }) {
310
- const integrations = integration.ScmIntegrations.fromConfig(config);
311
- scaffolderActions.addActions(
312
- createPublishAzureAction({
313
- integrations,
314
- config
315
- })
316
- );
317
- }
318
- });
319
- }
320
- });
321
-
322
- exports.createPublishAzureAction = createPublishAzureAction;
323
- exports.default = azureModule;
10
+ exports.createPublishAzureAction = azure.createPublishAzureAction;
11
+ exports.default = module$1.azureModule;
324
12
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/actions/azure.examples.ts","../src/actions/azure.ts","../src/module.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 git repository with the content in the workspace, and publishes it to Azure DevOps with the default configuration.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:azure',\n name: 'Publish to Azure',\n input: {\n repoUrl:\n 'dev.azure.com?organization=organization&project=project&repo=repo',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes an Azure DevOps repository with a description.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:azure',\n name: 'Publish to Azure',\n input: {\n repoUrl:\n 'dev.azure.com?organization=organization&project=project&repo=repo',\n description: 'Initialize a git repository',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes an Azure DevOps repository with a default branch, if not set defaults to master',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:azure',\n name: 'Publish to Azure',\n input: {\n repoUrl:\n 'dev.azure.com?organization=organization&project=project&repo=repo',\n defaultBranch: 'main',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes an Azure DevOps repository with a custom commit message',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:azure',\n name: 'Publish to Azure',\n input: {\n repoUrl:\n 'dev.azure.com?organization=organization&project=project&repo=repo',\n gitCommitMessage: 'Initial setup and configuration',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes an Azure DevOps repository with a custom author name and email',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:azure',\n name: 'Publish to Azure',\n input: {\n repoUrl:\n 'dev.azure.com?organization=organization&project=project&repo=repo',\n gitAuthorName: 'John Doe',\n gitAuthorEmail: 'john.doe@example.com',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes an Azure DevOps repository using a specific source path',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:azure',\n name: 'Publish to Azure',\n input: {\n repoUrl:\n 'dev.azure.com?organization=organization&project=project&repo=repo',\n sourcePath: 'path/to/source',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes an Azure DevOps repository using an authentication token',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:azure',\n name: 'Publish to Azure',\n input: {\n repoUrl:\n 'dev.azure.com?organization=organization&project=project&repo=repo',\n token: 'personal-access-token',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes an Azure DevOps repository using an custom repo url',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:azure',\n name: 'Publish to Azure',\n input: {\n repoUrl:\n 'test.azure.com?organization=organization&project=project&repo=repo',\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\nimport { InputError } from '@backstage/errors';\nimport {\n DefaultAzureDevOpsCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n initRepoAndPush,\n getRepoSourceDirectory,\n parseRepoUrl,\n createTemplateAction,\n} from '@backstage/plugin-scaffolder-node';\nimport { GitRepositoryCreateOptions } from 'azure-devops-node-api/interfaces/GitInterfaces';\nimport {\n getBearerHandler,\n getPersonalAccessTokenHandler,\n WebApi,\n} from 'azure-devops-node-api';\nimport { Config } from '@backstage/config';\nimport { examples } from './azure.examples';\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to Azure.\n * @public\n */\nexport function createPublishAzureAction(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 sourcePath?: string;\n token?: string;\n gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n }>({\n id: 'publish:azure',\n examples,\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to Azure.',\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 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: 'The token to use for authorization to Azure',\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 repositoryId: {\n title: 'The Id of the created 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 defaultBranch = 'master',\n gitCommitMessage = 'initial commit',\n gitAuthorName,\n gitAuthorEmail,\n } = ctx.input;\n\n const { project, repo, host, organization } = parseRepoUrl(\n repoUrl,\n integrations,\n );\n\n if (!organization) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing organization`,\n );\n }\n\n const url = `https://${host}/${organization}`;\n const credentialProvider =\n DefaultAzureDevOpsCredentialsProvider.fromIntegrations(integrations);\n const credentials = await credentialProvider.getCredentials({ url: url });\n\n if (credentials === undefined && ctx.input.token === undefined) {\n throw new InputError(\n `No credentials provided ${url}, please check your integrations config`,\n );\n }\n\n const authHandler =\n ctx.input.token || credentials?.type === 'pat'\n ? getPersonalAccessTokenHandler(ctx.input.token ?? credentials!.token)\n : getBearerHandler(credentials!.token);\n\n const webApi = new WebApi(url, authHandler);\n const client = await webApi.getGitApi();\n const createOptions: GitRepositoryCreateOptions = { name: repo };\n const returnedRepo = await client.createRepository(\n createOptions,\n project,\n );\n\n if (!returnedRepo) {\n throw new InputError(\n `Unable to create the repository with Organization ${organization}, Project ${project} and Repo ${repo}.\n Please make sure that both the Org and Project are typed corrected and exist.`,\n );\n }\n const remoteUrl = returnedRepo.remoteUrl;\n\n if (!remoteUrl) {\n throw new InputError(\n 'No remote URL returned from create repository for Azure',\n );\n }\n const repositoryId = returnedRepo.id;\n\n if (!repositoryId) {\n throw new InputError('No Id returned from create repository for Azure');\n }\n\n const repoContentsUrl = returnedRepo.webUrl;\n\n if (!repoContentsUrl) {\n throw new InputError(\n 'No web URL returned from create repository for Azure',\n );\n }\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 auth = {\n username: 'notempty',\n password: ctx.input.token ?? credentials!.token,\n };\n\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),\n remoteUrl,\n defaultBranch,\n auth: auth,\n logger: ctx.logger,\n commitMessage: gitCommitMessage\n ? gitCommitMessage\n : config.getOptionalString('scaffolder.defaultCommitMessage'),\n gitAuthorInfo,\n });\n\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n ctx.output('repositoryId', repositoryId);\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 createBackendModule,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport { createPublishAzureAction } from './actions';\n\n/**\n * @public\n * The Azure Module for the Scaffolder Backend\n */\nexport const azureModule = createBackendModule({\n moduleId: 'azure',\n pluginId: 'scaffolder',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolderActions: scaffolderActionsExtensionPoint,\n config: coreServices.rootConfig,\n },\n async init({ scaffolderActions, config }) {\n const integrations = ScmIntegrations.fromConfig(config);\n scaffolderActions.addActions(\n createPublishAzureAction({\n integrations,\n config,\n }),\n );\n },\n });\n },\n});\n"],"names":["yaml","createTemplateAction","parseRepoUrl","InputError","DefaultAzureDevOpsCredentialsProvider","getPersonalAccessTokenHandler","getBearerHandler","WebApi","initRepoAndPush","getRepoSourceDirectory","createBackendModule","scaffolderActionsExtensionPoint","coreServices","ScmIntegrations"],"mappings":";;;;;;;;;;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WACE,EAAA,kIAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,EAAA,eAAA;AAAA,UACR,IAAM,EAAA,kBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,mEAAA;AAAA,WACJ;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,4DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,EAAA,eAAA;AAAA,UACR,IAAM,EAA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A,EACV,QAAA,CAAS,EAAE,YAAA,EAAgB,EAAA;AACzB,IAAa,YAAA,CAAA;AAAA,MACX,IAAM,EAAA;AAAA,QACJ,iBAAmB,EAAAC,qCAAA;AAAA,QACnB,QAAQC,6BAAa,CAAA,UAAA;AAAA,OACvB;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,iBAAA,EAAmB,QAAU,EAAA;AACxC,QAAM,MAAA,YAAA,GAAeC,2BAAgB,CAAA,UAAA,CAAW,MAAM,CAAA,CAAA;AACtD,QAAkB,iBAAA,CAAA,UAAA;AAAA,UAChB,wBAAyB,CAAA;AAAA,YACvB,YAAA;AAAA,YACA,MAAA;AAAA,WACD,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ var backendPluginApi = require('@backstage/backend-plugin-api');
4
+ var integration = require('@backstage/integration');
5
+ var alpha = require('@backstage/plugin-scaffolder-node/alpha');
6
+ var azure = require('./actions/azure.cjs.js');
7
+
8
+ const azureModule = backendPluginApi.createBackendModule({
9
+ moduleId: "azure",
10
+ pluginId: "scaffolder",
11
+ register({ registerInit }) {
12
+ registerInit({
13
+ deps: {
14
+ scaffolderActions: alpha.scaffolderActionsExtensionPoint,
15
+ config: backendPluginApi.coreServices.rootConfig
16
+ },
17
+ async init({ scaffolderActions, config }) {
18
+ const integrations = integration.ScmIntegrations.fromConfig(config);
19
+ scaffolderActions.addActions(
20
+ azure.createPublishAzureAction({
21
+ integrations,
22
+ config
23
+ })
24
+ );
25
+ }
26
+ });
27
+ }
28
+ });
29
+
30
+ exports.azureModule = azureModule;
31
+ //# sourceMappingURL=module.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\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 createBackendModule,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport { createPublishAzureAction } from './actions';\n\n/**\n * @public\n * The Azure Module for the Scaffolder Backend\n */\nexport const azureModule = createBackendModule({\n moduleId: 'azure',\n pluginId: 'scaffolder',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolderActions: scaffolderActionsExtensionPoint,\n config: coreServices.rootConfig,\n },\n async init({ scaffolderActions, config }) {\n const integrations = ScmIntegrations.fromConfig(config);\n scaffolderActions.addActions(\n createPublishAzureAction({\n integrations,\n config,\n }),\n );\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","coreServices","ScmIntegrations","createPublishAzureAction"],"mappings":";;;;;;;AA2BO,MAAM,cAAcA,oCAAoB,CAAA;AAAA,EAC7C,QAAU,EAAA,OAAA;AAAA,EACV,QAAU,EAAA,YAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAgB,EAAA;AACzB,IAAa,YAAA,CAAA;AAAA,MACX,IAAM,EAAA;AAAA,QACJ,iBAAmB,EAAAC,qCAAA;AAAA,QACnB,QAAQC,6BAAa,CAAA,UAAA;AAAA,OACvB;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,iBAAA,EAAmB,QAAU,EAAA;AACxC,QAAM,MAAA,YAAA,GAAeC,2BAAgB,CAAA,UAAA,CAAW,MAAM,CAAA,CAAA;AACtD,QAAkB,iBAAA,CAAA,UAAA;AAAA,UAChBC,8BAAyB,CAAA;AAAA,YACvB,YAAA;AAAA,YACA,MAAA;AAAA,WACD,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-azure",
3
- "version": "0.2.1-next.1",
3
+ "version": "0.2.1",
4
4
  "description": "The azure module for @backstage/plugin-scaffolder-backend",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -40,16 +40,16 @@
40
40
  "test": "backstage-cli package test"
41
41
  },
42
42
  "dependencies": {
43
- "@backstage/backend-plugin-api": "1.0.1-next.0",
44
- "@backstage/config": "1.2.0",
45
- "@backstage/errors": "1.2.4",
46
- "@backstage/integration": "1.15.1-next.0",
47
- "@backstage/plugin-scaffolder-node": "0.5.0-next.1",
48
- "azure-devops-node-api": "^12.0.0",
43
+ "@backstage/backend-plugin-api": "^1.0.1",
44
+ "@backstage/config": "^1.2.0",
45
+ "@backstage/errors": "^1.2.4",
46
+ "@backstage/integration": "^1.15.1",
47
+ "@backstage/plugin-scaffolder-node": "^0.5.0",
48
+ "azure-devops-node-api": "^14.0.0",
49
49
  "yaml": "^2.0.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@backstage/cli": "0.28.0-next.1",
53
- "@backstage/plugin-scaffolder-node-test-utils": "0.1.13-next.1"
52
+ "@backstage/cli": "^0.28.0",
53
+ "@backstage/plugin-scaffolder-node-test-utils": "^0.1.13"
54
54
  }
55
55
  }