@backstage/plugin-scaffolder-backend-module-gitea 0.1.7 → 0.1.8-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 +12 -0
- package/README.md +38 -40
- package/dist/index.cjs.js +39 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-gitea
|
|
2
2
|
|
|
3
|
+
## 0.1.8-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 554af73: Allow defining `repoVisibility` field for the action `publish:gitea`
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/backend-plugin-api@0.6.18-next.0
|
|
10
|
+
- @backstage/plugin-scaffolder-node@0.4.4-next.0
|
|
11
|
+
- @backstage/config@1.2.0
|
|
12
|
+
- @backstage/errors@1.2.4
|
|
13
|
+
- @backstage/integration@1.10.0
|
|
14
|
+
|
|
3
15
|
## 0.1.7
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -10,6 +10,13 @@ To use this action, you will have to add the package using the following command
|
|
|
10
10
|
yarn --cwd packages/backend add @backstage/plugin-scaffolder-backend-module-gitea
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
Alternatively, if you use the new backend system, then register it like this:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
// packages/backend/src/index.ts
|
|
17
|
+
backend.add(import('@backstage/plugin-scaffolder-backend-module-gitea'));
|
|
18
|
+
```
|
|
19
|
+
|
|
13
20
|
Configure the action (if not yet done):
|
|
14
21
|
(you can check the [docs](https://backstage.io/docs/features/software-templates/writing-custom-actions#registering-custom-actions) to see all options):
|
|
15
22
|
|
|
@@ -27,29 +34,29 @@ integrations:
|
|
|
27
34
|
password: '<GITEA_LOCALHOST_PASSWORD>'
|
|
28
35
|
```
|
|
29
36
|
|
|
30
|
-
**Important**: As backstage will issue HTTPS/TLS requests to the gitea instance, it is needed to configure `gitea` with a valid certificate or at least with a
|
|
31
|
-
self-signed certificate `gitea cert --host localhost -ca` trusted by a CA authority. Don't forget to set the env var `NODE_EXTRA_CA_CERTS` to point to the CA file before launching backstage !
|
|
37
|
+
**Important**: As backstage will issue `HTTPS/TLS` requests to the gitea instance, it is needed to configure `gitea` with a valid certificate or at least with a
|
|
38
|
+
self-signed certificate `gitea cert --host localhost -ca` trusted by a CA authority. Don't forget to set the env var `NODE_EXTRA_CA_CERTS` to point to the CA file before launching backstage or you can set temporarily `NODE_TLS_REJECT_UNAUTHORIZED=0` but this is not recommended for production!
|
|
32
39
|
|
|
33
40
|
When done, you can create a template which:
|
|
34
41
|
|
|
35
|
-
- Declare the `RepoUrlPicker` within the `spec/parameters` section to select the gitea
|
|
36
|
-
-
|
|
42
|
+
- Declare the `RepoUrlPicker` within the `spec/parameters` section to select the gitea host and to provide the name of the repository
|
|
43
|
+
- Add an `enum` list allowing the user to define the visibility about the repository to be created: `public` or `private`. If this field is omitted, `public` is then used by the action.
|
|
44
|
+
- Include in a step the action: `publish:gitea`
|
|
45
|
+
|
|
46
|
+
**Warning**: The list of the `allowedOwners` of the `repoUrlPicker` must match the list of the `organizations` which are available on the gitea host !
|
|
37
47
|
|
|
38
48
|
```yaml
|
|
39
|
-
apiVersion: scaffolder.backstage.io/v1beta3
|
|
40
49
|
kind: Template
|
|
41
50
|
metadata:
|
|
42
|
-
name:
|
|
43
|
-
title:
|
|
44
|
-
description: Create a
|
|
45
|
-
tags:
|
|
46
|
-
- java
|
|
47
|
-
- quarkus
|
|
51
|
+
name: simple-gitea-project
|
|
52
|
+
title: Create a gitea repository
|
|
53
|
+
description: Create a gitea repository
|
|
48
54
|
spec:
|
|
49
|
-
owner:
|
|
55
|
+
owner: guests
|
|
50
56
|
type: service
|
|
57
|
+
|
|
51
58
|
parameters:
|
|
52
|
-
- title:
|
|
59
|
+
- title: Choose a location
|
|
53
60
|
required:
|
|
54
61
|
- repoUrl
|
|
55
62
|
properties:
|
|
@@ -58,42 +65,33 @@ spec:
|
|
|
58
65
|
type: string
|
|
59
66
|
ui:field: RepoUrlPicker
|
|
60
67
|
ui:options:
|
|
68
|
+
allowedOwners:
|
|
69
|
+
- qteam
|
|
70
|
+
- qshift
|
|
61
71
|
allowedHosts:
|
|
62
|
-
- gitea
|
|
63
|
-
- localhost:<PORT>
|
|
72
|
+
- gitea.localtest.me:3333
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
repoVisibility:
|
|
75
|
+
title: Visibility of the repository
|
|
76
|
+
type: string
|
|
77
|
+
default: 'public'
|
|
78
|
+
enum:
|
|
79
|
+
- 'public'
|
|
80
|
+
- 'private'
|
|
81
|
+
enumNames:
|
|
82
|
+
- 'public'
|
|
83
|
+
- 'private'
|
|
73
84
|
|
|
85
|
+
steps:
|
|
86
|
+
...
|
|
74
87
|
- id: publish
|
|
75
88
|
name: Publishing to a gitea git repository
|
|
76
89
|
action: publish:gitea
|
|
77
90
|
input:
|
|
78
|
-
description: This is ${{ parameters.
|
|
91
|
+
description: This is ${{ parameters.repoUrl | parseRepoUrl | pick('repo') }}
|
|
92
|
+
repoVisibility: ${{ parameters.repoVisibility }}
|
|
79
93
|
repoUrl: ${{ parameters.repoUrl }}
|
|
80
94
|
defaultBranch: main
|
|
81
|
-
|
|
82
|
-
- id: register
|
|
83
|
-
if: ${{ parameters.dryRun !== true }}
|
|
84
|
-
name: Register
|
|
85
|
-
action: catalog:register
|
|
86
|
-
input:
|
|
87
|
-
repoContentsUrl: ${{ steps['publish'].output.repoContentsUrl }}
|
|
88
|
-
catalogInfoPath: 'main/catalog-info.yaml'
|
|
89
|
-
|
|
90
|
-
output:
|
|
91
|
-
links:
|
|
92
|
-
- title: Source Code Repository
|
|
93
|
-
url: ${{ steps.publish.output.remoteUrl }}
|
|
94
|
-
- title: Open Component in catalog
|
|
95
|
-
icon: catalog
|
|
96
|
-
entityRef: ${{ steps.register.output.entityRef }}
|
|
97
95
|
```
|
|
98
96
|
|
|
99
97
|
Access the newly gitea repository created using the `repoContentsUrl` ;-)
|
package/dist/index.cjs.js
CHANGED
|
@@ -47,6 +47,23 @@ const examples = [
|
|
|
47
47
|
]
|
|
48
48
|
})
|
|
49
49
|
},
|
|
50
|
+
{
|
|
51
|
+
description: "Initializes a private Gitea repository ",
|
|
52
|
+
example: yaml__default.default.stringify({
|
|
53
|
+
steps: [
|
|
54
|
+
{
|
|
55
|
+
id: "publish",
|
|
56
|
+
action: "publish:gitea",
|
|
57
|
+
name: "Publish to Gitea",
|
|
58
|
+
input: {
|
|
59
|
+
repoUrl: "gitea.com?repo=repo&owner=owner",
|
|
60
|
+
defaultBranch: "main",
|
|
61
|
+
repoVisibility: "private"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
})
|
|
66
|
+
},
|
|
50
67
|
{
|
|
51
68
|
description: "Initializes a Gitea repository with a default Branch, if not set defaults to main",
|
|
52
69
|
example: yaml__default.default.stringify({
|
|
@@ -142,7 +159,8 @@ const examples = [
|
|
|
142
159
|
gitCommitMessage: "Initial Commit Message",
|
|
143
160
|
gitAuthorName: "John Doe",
|
|
144
161
|
gitAuthorEmail: "johndoe@email.com",
|
|
145
|
-
sourcePath: "repository/"
|
|
162
|
+
sourcePath: "repository/",
|
|
163
|
+
repoVisibility: "public"
|
|
146
164
|
}
|
|
147
165
|
}
|
|
148
166
|
]
|
|
@@ -185,7 +203,7 @@ const checkGiteaOrg = async (config, options) => {
|
|
|
185
203
|
);
|
|
186
204
|
} catch (e) {
|
|
187
205
|
throw new Error(
|
|
188
|
-
`Unable to get the Organization: ${owner}; Error cause: ${e.cause.
|
|
206
|
+
`Unable to get the Organization: ${owner}; Error cause: ${e.message}, code: ${e.cause.code}`
|
|
189
207
|
);
|
|
190
208
|
}
|
|
191
209
|
if (response.status !== 200) {
|
|
@@ -195,13 +213,22 @@ const checkGiteaOrg = async (config, options) => {
|
|
|
195
213
|
}
|
|
196
214
|
};
|
|
197
215
|
const createGiteaProject = async (config, options) => {
|
|
198
|
-
const { projectName, description, owner } = options;
|
|
216
|
+
const { projectName, description, owner, repoVisibility } = options;
|
|
199
217
|
let response;
|
|
218
|
+
let isPrivate;
|
|
219
|
+
if (repoVisibility === "private") {
|
|
220
|
+
isPrivate = true;
|
|
221
|
+
} else if (repoVisibility === "public") {
|
|
222
|
+
isPrivate = false;
|
|
223
|
+
} else {
|
|
224
|
+
isPrivate = false;
|
|
225
|
+
}
|
|
200
226
|
const postOptions = {
|
|
201
227
|
method: "POST",
|
|
202
228
|
body: JSON.stringify({
|
|
203
229
|
name: projectName,
|
|
204
|
-
description
|
|
230
|
+
description,
|
|
231
|
+
private: isPrivate
|
|
205
232
|
}),
|
|
206
233
|
headers: {
|
|
207
234
|
...integration.getGiteaRequestOptions(config).headers,
|
|
@@ -274,6 +301,12 @@ function createPublishGiteaAction(options) {
|
|
|
274
301
|
type: "string",
|
|
275
302
|
description: `Sets the default branch on the repository. The default value is 'main'`
|
|
276
303
|
},
|
|
304
|
+
repoVisibility: {
|
|
305
|
+
title: "Repository Visibility",
|
|
306
|
+
description: `Sets the visibility of the repository. The default value is 'public'.`,
|
|
307
|
+
type: "string",
|
|
308
|
+
enum: ["private", "public"]
|
|
309
|
+
},
|
|
277
310
|
gitCommitMessage: {
|
|
278
311
|
title: "Git Commit Message",
|
|
279
312
|
type: "string",
|
|
@@ -319,6 +352,7 @@ function createPublishGiteaAction(options) {
|
|
|
319
352
|
repoUrl,
|
|
320
353
|
description,
|
|
321
354
|
defaultBranch = "main",
|
|
355
|
+
repoVisibility = "public",
|
|
322
356
|
gitAuthorName,
|
|
323
357
|
gitAuthorEmail,
|
|
324
358
|
gitCommitMessage = "initial commit",
|
|
@@ -340,6 +374,7 @@ function createPublishGiteaAction(options) {
|
|
|
340
374
|
}
|
|
341
375
|
await createGiteaProject(integrationConfig.config, {
|
|
342
376
|
description,
|
|
377
|
+
repoVisibility,
|
|
343
378
|
owner,
|
|
344
379
|
projectName: repo
|
|
345
380
|
});
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/actions/gitea.examples.ts","../src/actions/gitea.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 Gitea with the default configuration.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a Gitea repository with a description.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n description: 'Initialize a gitea repository',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Gitea repository with a default Branch, if not set defaults to main',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n defaultBranch: 'main',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Gitea repository with an initial commit message, if not set defaults to `initial commit`',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n gitCommitMessage: 'Initial Commit Message',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Gitea repository with a repo Author Name, if not set defaults to Scaffolder',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n gitAuthorName: 'John Doe',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a Gitea repository with a repo Author Email',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n gitAuthorEmail: 'johndoe@email.com',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n sourcePath: 'repository/',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a Gitea repository with all properties being set',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n description: 'Initialize a gitea repository',\n defaultBranch: 'staging',\n gitCommitMessage: 'Initial Commit Message',\n gitAuthorName: 'John Doe',\n gitAuthorEmail: 'johndoe@email.com',\n sourcePath: 'repository/',\n },\n },\n ],\n }),\n },\n];\n","/*\n * Copyright 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 { InputError } from '@backstage/errors';\nimport { Config } from '@backstage/config';\nimport {\n getGiteaRequestOptions,\n GiteaIntegrationConfig,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n ActionContext,\n createTemplateAction,\n getRepoSourceDirectory,\n initRepoAndPush,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './gitea.examples';\nimport crypto from 'crypto';\n\nconst checkGiteaContentUrl = async (\n config: GiteaIntegrationConfig,\n options: {\n owner?: string;\n repo: string;\n defaultBranch?: string;\n },\n): Promise<Response> => {\n const { owner, repo, defaultBranch } = options;\n let response: Response;\n const getOptions: RequestInit = {\n method: 'GET',\n };\n\n try {\n response = await fetch(\n `${config.baseUrl}/${owner}/${repo}/src/branch/${defaultBranch}`,\n getOptions,\n );\n } catch (e) {\n throw new Error(\n `Unable to get the repository: ${owner}/${repo} metadata , ${e}`,\n );\n }\n return response;\n};\n\nconst checkGiteaOrg = async (\n config: GiteaIntegrationConfig,\n options: {\n owner: string;\n },\n): Promise<void> => {\n const { owner } = options;\n let response: Response;\n // check first if the org = owner exists\n const getOptions: RequestInit = {\n method: 'GET',\n headers: {\n ...getGiteaRequestOptions(config).headers,\n 'Content-Type': 'application/json',\n },\n };\n try {\n response = await fetch(\n `${config.baseUrl}/api/v1/orgs/${owner}`,\n getOptions,\n );\n } catch (e) {\n throw new Error(\n `Unable to get the Organization: ${owner}; Error cause: ${e.cause.message}`,\n );\n }\n if (response.status !== 200) {\n throw new Error(\n `Organization ${owner} do not exist. Please create it first !`,\n );\n }\n};\n\nconst createGiteaProject = async (\n config: GiteaIntegrationConfig,\n options: {\n projectName: string;\n owner?: string;\n description: string;\n },\n): Promise<void> => {\n const { projectName, description, owner } = options;\n\n /*\n Several options exist to create a repository using either the user or organisation\n User: https://gitea.com/api/swagger#/user/createCurrentUserRepo\n Api: URL/api/v1/user/repos\n Remark: The user is the username defined part of the backstage integration config for the gitea URL !\n\n Org: https://gitea.com/api/swagger#/organization/createOrgRepo\n Api: URL/api/v1/orgs/${org_owner}/repos\n This is the default scenario that we support currently\n */\n let response: Response;\n\n const postOptions: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n name: projectName,\n description,\n }),\n headers: {\n ...getGiteaRequestOptions(config).headers,\n 'Content-Type': 'application/json',\n },\n };\n try {\n response = await fetch(\n `${config.baseUrl}/api/v1/orgs/${owner}/repos`,\n postOptions,\n );\n } catch (e) {\n throw new Error(`Unable to create repository, ${e}`);\n }\n if (response.status !== 201) {\n throw new Error(\n `Unable to create repository, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n};\n\nconst generateCommitMessage = (\n config: Config,\n commitSubject?: string,\n): string => {\n const changeId = crypto.randomBytes(20).toString('hex');\n const msg = `${\n config.getOptionalString('scaffolder.defaultCommitMessage') || commitSubject\n }\\n\\nChange-Id: I${changeId}`;\n return msg;\n};\n\nasync function checkAvailabilityGiteaRepository(\n maxDuration: number,\n integrationConfig: GiteaIntegrationConfig,\n options: {\n owner?: string;\n repo: string;\n defaultBranch: string;\n ctx: ActionContext<any>;\n },\n) {\n const startTimestamp = Date.now();\n\n const { owner, repo, defaultBranch, ctx } = options;\n const sleep = (ms: number | undefined) => new Promise(r => setTimeout(r, ms));\n let response: Response;\n\n while (Date.now() - startTimestamp < maxDuration) {\n if (ctx.signal?.aborted) return;\n\n response = await checkGiteaContentUrl(integrationConfig, {\n owner,\n repo,\n defaultBranch,\n });\n\n if (response.status !== 200) {\n // Repository is not yet available/accessible ...\n await sleep(1000);\n } else {\n // Gitea repository exists !\n break;\n }\n }\n}\n\n/**\n * Creates a new action that initializes a git repository using the content of the workspace.\n * and publishes it to a Gitea instance.\n * @public\n */\nexport function createPublishGiteaAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n description: string;\n defaultBranch?: string;\n gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n sourcePath?: string;\n }>({\n id: 'publish:gitea',\n description:\n 'Initializes a git repository using the content of the workspace, and publishes it to Gitea.',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n description: {\n title: 'Repository Description',\n type: 'string',\n },\n defaultBranch: {\n title: 'Default Branch',\n type: 'string',\n description: `Sets the default branch on the repository. The default value is 'main'`,\n },\n gitCommitMessage: {\n title: 'Git Commit Message',\n type: 'string',\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n },\n gitAuthorName: {\n title: 'Default Author Name',\n type: 'string',\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n },\n gitAuthorEmail: {\n title: 'Default Author Email',\n type: 'string',\n description: `Sets the default author email for the commit.`,\n },\n sourcePath: {\n title: 'Source Path',\n type: 'string',\n description: `Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.`,\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n remoteUrl: {\n title: 'A URL to the repository with the provider',\n type: 'string',\n },\n repoContentsUrl: {\n title: 'A URL to the root of the repository',\n type: 'string',\n },\n commitHash: {\n title: 'The git commit hash of the initial commit',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n defaultBranch = 'main',\n gitAuthorName,\n gitAuthorEmail,\n gitCommitMessage = 'initial commit',\n sourcePath,\n } = ctx.input;\n\n const { repo, host, owner } = parseRepoUrl(repoUrl, integrations);\n\n const integrationConfig = integrations.gitea.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 const { username, password } = integrationConfig.config;\n\n if (!username || !password) {\n throw new Error('Credentials for the gitea ${host} required.');\n }\n\n // check if the org exists within the gitea server\n if (owner) {\n await checkGiteaOrg(integrationConfig.config, { owner });\n }\n\n await createGiteaProject(integrationConfig.config, {\n description,\n owner: owner,\n projectName: repo,\n });\n\n const auth = {\n username: username,\n password: password,\n };\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n // The owner to be used should be either the org name or user authenticated with the gitea server\n const remoteUrl = `${integrationConfig.config.baseUrl}/${owner}/${repo}.git`;\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(ctx.workspacePath, sourcePath),\n remoteUrl,\n auth,\n defaultBranch,\n logger: ctx.logger,\n commitMessage: generateCommitMessage(config, gitCommitMessage),\n gitAuthorInfo,\n });\n\n // Check if the gitea repo URL is available before to exit\n const maxDuration = 20000; // 20 seconds\n await checkAvailabilityGiteaRepository(\n maxDuration,\n integrationConfig.config,\n {\n owner,\n repo,\n defaultBranch,\n ctx,\n },\n );\n\n const repoContentsUrl = `${integrationConfig.config.baseUrl}/${owner}/${repo}/src/branch/${defaultBranch}/`;\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('repoContentsUrl', repoContentsUrl);\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 { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport { createPublishGiteaAction } from './actions';\nimport { ScmIntegrations } from '@backstage/integration';\n\n/**\n * @public\n * The Gitea Module for the Scaffolder Backend\n */\nexport const giteaModule = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'gitea',\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 scaffolder.addActions(\n createPublishGiteaAction({\n integrations,\n config,\n }),\n );\n },\n });\n },\n});\n"],"names":["yaml","getGiteaRequestOptions","crypto","createTemplateAction","parseRepoUrl","InputError","initRepoAndPush","getRepoSourceDirectory","createBackendModule","scaffolderActionsExtensionPoint","coreServices","ScmIntegrations"],"mappings":";;;;;;;;;;;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WACE,EAAA,2HAAA;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,OAAS,EAAA,iCAAA;AAAA,WACX;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,oDAAA;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,EAAA,kBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,iCAAA;AAAA,YACT,WAAa,EAAA,+BAAA;AAAA,WACf;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH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S,CAAA,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,YAAc,EAAA,YAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,YAAA,CAAc,UAAU,CAAA,CAAA;AACjD,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA,CAAA;AAAA,KAC/C;AAAA,GACD,CAAA,CAAA;AACH;;ACnUO,MAAM,cAAcC,oCAAoB,CAAA;AAAA,EAC7C,QAAU,EAAA,YAAA;AAAA,EACV,QAAU,EAAA,OAAA;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;AACtD,QAAW,UAAA,CAAA,UAAA;AAAA,UACT,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":["../src/actions/gitea.examples.ts","../src/actions/gitea.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 Gitea with the default configuration.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a Gitea repository with a description.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n description: 'Initialize a gitea repository',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a private Gitea repository ',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n defaultBranch: 'main',\n repoVisibility: 'private',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Gitea repository with a default Branch, if not set defaults to main',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n defaultBranch: 'main',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Gitea repository with an initial commit message, if not set defaults to `initial commit`',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n gitCommitMessage: 'Initial Commit Message',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Gitea repository with a repo Author Name, if not set defaults to Scaffolder',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n gitAuthorName: 'John Doe',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a Gitea repository with a repo Author Email',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n gitAuthorEmail: 'johndoe@email.com',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n sourcePath: 'repository/',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a Gitea repository with all properties being set',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gitea',\n name: 'Publish to Gitea',\n input: {\n repoUrl: 'gitea.com?repo=repo&owner=owner',\n description: 'Initialize a gitea repository',\n defaultBranch: 'staging',\n gitCommitMessage: 'Initial Commit Message',\n gitAuthorName: 'John Doe',\n gitAuthorEmail: 'johndoe@email.com',\n sourcePath: 'repository/',\n repoVisibility: 'public',\n },\n },\n ],\n }),\n },\n];\n","/*\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 { InputError } from '@backstage/errors';\nimport { Config } from '@backstage/config';\nimport {\n getGiteaRequestOptions,\n GiteaIntegrationConfig,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n ActionContext,\n createTemplateAction,\n getRepoSourceDirectory,\n initRepoAndPush,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './gitea.examples';\nimport crypto from 'crypto';\n\nconst checkGiteaContentUrl = async (\n config: GiteaIntegrationConfig,\n options: {\n owner?: string;\n repo: string;\n defaultBranch?: string;\n },\n): Promise<Response> => {\n const { owner, repo, defaultBranch } = options;\n let response: Response;\n const getOptions: RequestInit = {\n method: 'GET',\n };\n\n try {\n response = await fetch(\n `${config.baseUrl}/${owner}/${repo}/src/branch/${defaultBranch}`,\n getOptions,\n );\n } catch (e) {\n throw new Error(\n `Unable to get the repository: ${owner}/${repo} metadata , ${e}`,\n );\n }\n return response;\n};\n\nconst checkGiteaOrg = async (\n config: GiteaIntegrationConfig,\n options: {\n owner: string;\n },\n): Promise<void> => {\n const { owner } = options;\n let response: Response;\n // check first if the org = owner exists\n const getOptions: RequestInit = {\n method: 'GET',\n headers: {\n ...getGiteaRequestOptions(config).headers,\n 'Content-Type': 'application/json',\n },\n };\n try {\n response = await fetch(\n `${config.baseUrl}/api/v1/orgs/${owner}`,\n getOptions,\n );\n } catch (e) {\n throw new Error(\n `Unable to get the Organization: ${owner}; Error cause: ${e.message}, code: ${e.cause.code}`,\n );\n }\n if (response.status !== 200) {\n throw new Error(\n `Organization ${owner} do not exist. Please create it first !`,\n );\n }\n};\n\nconst createGiteaProject = async (\n config: GiteaIntegrationConfig,\n options: {\n projectName: string;\n owner?: string;\n repoVisibility?: string;\n description: string;\n },\n): Promise<void> => {\n const { projectName, description, owner, repoVisibility } = options;\n\n /*\n Several options exist to create a repository using either the user or organisation\n User: https://gitea.com/api/swagger#/user/createCurrentUserRepo\n Api: URL/api/v1/user/repos\n Remark: The user is the username defined part of the backstage integration config for the gitea URL !\n\n Org: https://gitea.com/api/swagger#/organization/createOrgRepo\n Api: URL/api/v1/orgs/${org_owner}/repos\n This is the default scenario that we support currently\n */\n let response: Response;\n let isPrivate: boolean;\n\n if (repoVisibility === 'private') {\n isPrivate = true;\n } else if (repoVisibility === 'public') {\n isPrivate = false;\n } else {\n // Provide a default value if repoVisibility is neither \"private\" nor \"public\"\n isPrivate = false;\n }\n\n const postOptions: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n name: projectName,\n description,\n private: isPrivate,\n }),\n headers: {\n ...getGiteaRequestOptions(config).headers,\n 'Content-Type': 'application/json',\n },\n };\n try {\n response = await fetch(\n `${config.baseUrl}/api/v1/orgs/${owner}/repos`,\n postOptions,\n );\n } catch (e) {\n throw new Error(`Unable to create repository, ${e}`);\n }\n if (response.status !== 201) {\n throw new Error(\n `Unable to create repository, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n};\n\nconst generateCommitMessage = (\n config: Config,\n commitSubject?: string,\n): string => {\n const changeId = crypto.randomBytes(20).toString('hex');\n const msg = `${\n config.getOptionalString('scaffolder.defaultCommitMessage') || commitSubject\n }\\n\\nChange-Id: I${changeId}`;\n return msg;\n};\n\nasync function checkAvailabilityGiteaRepository(\n maxDuration: number,\n integrationConfig: GiteaIntegrationConfig,\n options: {\n owner?: string;\n repo: string;\n defaultBranch: string;\n ctx: ActionContext<any>;\n },\n) {\n const startTimestamp = Date.now();\n\n const { owner, repo, defaultBranch, ctx } = options;\n const sleep = (ms: number | undefined) => new Promise(r => setTimeout(r, ms));\n let response: Response;\n\n while (Date.now() - startTimestamp < maxDuration) {\n if (ctx.signal?.aborted) return;\n\n response = await checkGiteaContentUrl(integrationConfig, {\n owner,\n repo,\n defaultBranch,\n });\n\n if (response.status !== 200) {\n // Repository is not yet available/accessible ...\n await sleep(1000);\n } else {\n // Gitea repository exists !\n break;\n }\n }\n}\n\n/**\n * Creates a new action that initializes a git repository using the content of the workspace.\n * and publishes it to a Gitea instance.\n * @public\n */\nexport function createPublishGiteaAction(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 gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n sourcePath?: string;\n }>({\n id: 'publish:gitea',\n description:\n 'Initializes a git repository using the content of the workspace, and publishes it to Gitea.',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n description: {\n title: 'Repository Description',\n type: 'string',\n },\n defaultBranch: {\n title: 'Default Branch',\n type: 'string',\n description: `Sets the default branch on the repository. The default value is 'main'`,\n },\n repoVisibility: {\n title: 'Repository Visibility',\n description: `Sets the visibility of the repository. The default value is 'public'.`,\n type: 'string',\n enum: ['private', 'public'],\n },\n gitCommitMessage: {\n title: 'Git Commit Message',\n type: 'string',\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n },\n gitAuthorName: {\n title: 'Default Author Name',\n type: 'string',\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n },\n gitAuthorEmail: {\n title: 'Default Author Email',\n type: 'string',\n description: `Sets the default author email for the commit.`,\n },\n sourcePath: {\n title: 'Source Path',\n type: 'string',\n description: `Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.`,\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n remoteUrl: {\n title: 'A URL to the repository with the provider',\n type: 'string',\n },\n repoContentsUrl: {\n title: 'A URL to the root of the repository',\n type: 'string',\n },\n commitHash: {\n title: 'The git commit hash of the initial commit',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n defaultBranch = 'main',\n repoVisibility = 'public',\n gitAuthorName,\n gitAuthorEmail,\n gitCommitMessage = 'initial commit',\n sourcePath,\n } = ctx.input;\n\n const { repo, host, owner } = parseRepoUrl(repoUrl, integrations);\n\n const integrationConfig = integrations.gitea.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 const { username, password } = integrationConfig.config;\n\n if (!username || !password) {\n throw new Error('Credentials for the gitea ${host} required.');\n }\n\n // check if the org exists within the gitea server\n if (owner) {\n await checkGiteaOrg(integrationConfig.config, { owner });\n }\n\n await createGiteaProject(integrationConfig.config, {\n description,\n repoVisibility,\n owner: owner,\n projectName: repo,\n });\n\n const auth = {\n username: username,\n password: password,\n };\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n // The owner to be used should be either the org name or user authenticated with the gitea server\n const remoteUrl = `${integrationConfig.config.baseUrl}/${owner}/${repo}.git`;\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(ctx.workspacePath, sourcePath),\n remoteUrl,\n auth,\n defaultBranch,\n logger: ctx.logger,\n commitMessage: generateCommitMessage(config, gitCommitMessage),\n gitAuthorInfo,\n });\n\n // Check if the gitea repo URL is available before to exit\n const maxDuration = 20000; // 20 seconds\n await checkAvailabilityGiteaRepository(\n maxDuration,\n integrationConfig.config,\n {\n owner,\n repo,\n defaultBranch,\n ctx,\n },\n );\n\n const repoContentsUrl = `${integrationConfig.config.baseUrl}/${owner}/${repo}/src/branch/${defaultBranch}/`;\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('repoContentsUrl', repoContentsUrl);\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 { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport { createPublishGiteaAction } from './actions';\nimport { ScmIntegrations } from '@backstage/integration';\n\n/**\n * @public\n * The Gitea Module for the Scaffolder Backend\n */\nexport const giteaModule = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'gitea',\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 scaffolder.addActions(\n createPublishGiteaAction({\n integrations,\n config,\n }),\n );\n },\n });\n },\n});\n"],"names":["yaml","getGiteaRequestOptions","crypto","createTemplateAction","parseRepoUrl","InputError","initRepoAndPush","getRepoSourceDirectory","createBackendModule","scaffolderActionsExtensionPoint","coreServices","ScmIntegrations"],"mappings":";;;;;;;;;;;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WACE,EAAA,2HAAA;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,OAAS,EAAA,iCAAA;AAAA,WACX;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,oDAAA;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,EAAA,kBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,iCAAA;AAAA,YACT,WAAa,EAAA,+BAAA;AAAA,WACf;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,yCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,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AA,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;AACtD,QAAW,UAAA,CAAA,UAAA;AAAA,UACT,wBAAyB,CAAA;AAAA,YACvB,YAAA;AAAA,YACA,MAAA;AAAA,WACD,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ declare function createPublishGiteaAction(options: {
|
|
|
16
16
|
repoUrl: string;
|
|
17
17
|
description: string;
|
|
18
18
|
defaultBranch?: string | undefined;
|
|
19
|
+
repoVisibility?: "private" | "public" | undefined;
|
|
19
20
|
gitCommitMessage?: string | undefined;
|
|
20
21
|
gitAuthorName?: string | undefined;
|
|
21
22
|
gitAuthorEmail?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-scaffolder-backend-module-gitea",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8-next.0",
|
|
4
4
|
"description": "The gitea module for @backstage/plugin-scaffolder-backend",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module"
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"test": "backstage-cli package test"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@backstage/backend-plugin-api": "^0.6.
|
|
40
|
+
"@backstage/backend-plugin-api": "^0.6.18-next.0",
|
|
41
41
|
"@backstage/config": "^1.2.0",
|
|
42
42
|
"@backstage/errors": "^1.2.4",
|
|
43
43
|
"@backstage/integration": "^1.10.0",
|
|
44
|
-
"@backstage/plugin-scaffolder-node": "^0.4.
|
|
44
|
+
"@backstage/plugin-scaffolder-node": "^0.4.4-next.0",
|
|
45
45
|
"node-fetch": "^2.6.7",
|
|
46
46
|
"yaml": "^2.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@backstage/backend-test-utils": "^0.3.
|
|
50
|
-
"@backstage/cli": "^0.26.
|
|
51
|
-
"@backstage/plugin-scaffolder-node-test-utils": "^0.1.
|
|
49
|
+
"@backstage/backend-test-utils": "^0.3.8-next.0",
|
|
50
|
+
"@backstage/cli": "^0.26.5-next.0",
|
|
51
|
+
"@backstage/plugin-scaffolder-node-test-utils": "^0.1.4-next.0",
|
|
52
52
|
"msw": "^1.0.0"
|
|
53
53
|
}
|
|
54
54
|
}
|