@backstage/plugin-scaffolder-backend-module-gitea 0.2.10-next.0 → 0.2.10-next.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,17 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-gitea
2
2
 
3
+ ## 0.2.10-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - ed41017: Migrate to new actions format
8
+ - Updated dependencies
9
+ - @backstage/plugin-scaffolder-node@0.8.3-next.1
10
+ - @backstage/backend-plugin-api@1.4.0-next.1
11
+ - @backstage/config@1.3.2
12
+ - @backstage/errors@1.2.7
13
+ - @backstage/integration@1.17.0
14
+
3
15
  ## 0.2.10-next.0
4
16
 
5
17
  ### Patch Changes
@@ -125,71 +125,44 @@ function createPublishGiteaAction(options) {
125
125
  examples: gitea_examples.examples,
126
126
  schema: {
127
127
  input: {
128
- type: "object",
129
- required: ["repoUrl"],
130
- properties: {
131
- repoUrl: {
132
- title: "Repository Location",
133
- type: "string"
134
- },
135
- description: {
136
- title: "Repository Description",
137
- type: "string"
138
- },
139
- defaultBranch: {
140
- title: "Default Branch",
141
- type: "string",
142
- description: `Sets the default branch on the repository. The default value is 'main'`
143
- },
144
- repoVisibility: {
145
- title: "Repository Visibility",
146
- description: `Sets the visibility of the repository. The default value is 'public'.`,
147
- type: "string",
148
- enum: ["private", "public"]
149
- },
150
- gitCommitMessage: {
151
- title: "Git Commit Message",
152
- type: "string",
153
- description: `Sets the commit message on the repository. The default value is 'initial commit'`
154
- },
155
- gitAuthorName: {
156
- title: "Default Author Name",
157
- type: "string",
158
- description: `Sets the default author name for the commit. The default value is 'Scaffolder'`
159
- },
160
- gitAuthorEmail: {
161
- title: "Default Author Email",
162
- type: "string",
163
- description: `Sets the default author email for the commit.`
164
- },
165
- sourcePath: {
166
- title: "Source Path",
167
- type: "string",
168
- description: `Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.`
169
- },
170
- signCommit: {
171
- title: "Sign commit",
172
- type: "boolean",
173
- description: "Sign commit with configured PGP private key"
174
- }
175
- }
128
+ repoUrl: (z) => z.string({
129
+ description: "Repository Location"
130
+ }),
131
+ description: (z) => z.string({
132
+ description: "Repository Description"
133
+ }),
134
+ defaultBranch: (z) => z.string({
135
+ description: `Sets the default branch on the repository. The default value is 'main'`
136
+ }).optional(),
137
+ repoVisibility: (z) => z.enum(["private", "public"], {
138
+ description: `Sets the visibility of the repository. The default value is 'public'.`
139
+ }).optional(),
140
+ gitCommitMessage: (z) => z.string({
141
+ description: `Sets the commit message on the repository. The default value is 'initial commit'`
142
+ }).optional(),
143
+ gitAuthorName: (z) => z.string({
144
+ description: `Sets the default author name for the commit. The default value is 'Scaffolder'`
145
+ }).optional(),
146
+ gitAuthorEmail: (z) => z.string({
147
+ description: `Sets the default author email for the commit.`
148
+ }).optional(),
149
+ sourcePath: (z) => z.string({
150
+ description: `Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.`
151
+ }).optional(),
152
+ signCommit: (z) => z.boolean({
153
+ description: "Sign commit with configured PGP private key"
154
+ }).optional()
176
155
  },
177
156
  output: {
178
- type: "object",
179
- properties: {
180
- remoteUrl: {
181
- title: "A URL to the repository with the provider",
182
- type: "string"
183
- },
184
- repoContentsUrl: {
185
- title: "A URL to the root of the repository",
186
- type: "string"
187
- },
188
- commitHash: {
189
- title: "The git commit hash of the initial commit",
190
- type: "string"
191
- }
192
- }
157
+ remoteUrl: (z) => z.string({
158
+ description: "A URL to the repository with the provider"
159
+ }).optional(),
160
+ repoContentsUrl: (z) => z.string({
161
+ description: "A URL to the root of the repository"
162
+ }).optional(),
163
+ commitHash: (z) => z.string({
164
+ description: "The git commit hash of the initial commit"
165
+ }).optional()
193
166
  }
194
167
  },
195
168
  async handler(ctx) {
@@ -1 +1 @@
1
- {"version":3,"file":"gitea.cjs.js","sources":["../../src/actions/gitea.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 { 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 signCommit?: boolean;\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 signCommit: {\n title: 'Sign commit',\n type: 'boolean',\n description: 'Sign commit with configured PGP private key',\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 signCommit,\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\n const signingKey =\n integrationConfig.config.commitSigningKey ??\n config.getOptionalString('scaffolder.defaultCommitSigningKey');\n if (signCommit && !signingKey) {\n throw new Error(\n 'Signing commits is enabled but no signing key is provided in the configuration',\n );\n }\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"],"names":["getGiteaRequestOptions","crypto","createTemplateAction","examples","parseRepoUrl","InputError","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;;;;;;;AAiCA,MAAM,oBAAA,GAAuB,OAC3B,MAAA,EACA,OAKsB,KAAA;AACtB,EAAA,MAAM,EAAE,KAAA,EAAO,IAAM,EAAA,aAAA,EAAkB,GAAA,OAAA;AACvC,EAAI,IAAA,QAAA;AACJ,EAAA,MAAM,UAA0B,GAAA;AAAA,IAC9B,MAAQ,EAAA;AAAA,GACV;AAEA,EAAI,IAAA;AACF,IAAA,QAAA,GAAW,MAAM,KAAA;AAAA,MACf,CAAA,EAAG,OAAO,OAAO,CAAA,CAAA,EAAI,KAAK,CAAI,CAAA,EAAA,IAAI,eAAe,aAAa,CAAA,CAAA;AAAA,MAC9D;AAAA,KACF;AAAA,WACO,CAAG,EAAA;AACV,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAiC,8BAAA,EAAA,KAAK,CAAI,CAAA,EAAA,IAAI,eAAe,CAAC,CAAA;AAAA,KAChE;AAAA;AAEF,EAAO,OAAA,QAAA;AACT,CAAA;AAEA,MAAM,aAAA,GAAgB,OACpB,MAAA,EACA,OAGkB,KAAA;AAClB,EAAM,MAAA,EAAE,OAAU,GAAA,OAAA;AAClB,EAAI,IAAA,QAAA;AAEJ,EAAA,MAAM,UAA0B,GAAA;AAAA,IAC9B,MAAQ,EAAA,KAAA;AAAA,IACR,OAAS,EAAA;AAAA,MACP,GAAGA,kCAAuB,C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MAAA,CAAO,OAAO,CAAI,CAAA,EAAA,KAAK,IAAI,IAAI,CAAA,IAAA,CAAA;AACtE,MAAM,MAAA,YAAA,GAAe,MAAMC,oCAAgB,CAAA;AAAA,QACzC,GAAK,EAAAC,2CAAA,CAAuB,GAAI,CAAA,aAAA,EAAe,UAAU,CAAA;AAAA,QACzD,SAAA;AAAA,QACA,IAAA;AAAA,QACA,aAAA;AAAA,QACA,QAAQ,GAAI,CAAA,MAAA;AAAA,QACZ,aAAA,EAAe,qBAAsB,CAAA,MAAA,EAAQ,gBAAgB,CAAA;AAAA,QAC7D;AAAA,OACD,CAAA;AAGD,MAAA,MAAM,WAAc,GAAA,GAAA;AACpB,MAAM,MAAA,gCAAA;AAAA,QACJ,WAAA;AAAA,QACA,iBAAkB,CAAA,MAAA;AAAA,QAClB;AAAA,UACE,KAAA;AAAA,UACA,IAAA;AAAA,UACA,aAAA;AAAA,UACA;AAAA;AACF,OACF;AAEA,MAAM,MAAA,eAAA,GAAkB,CAAG,EAAA,iBAAA,CAAkB,MAAO,CAAA,OAAO,IAAI,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,YAAA,EAAe,aAAa,CAAA,CAAA,CAAA;AACxG,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,YAAc,EAAA,YAAA,EAAc,UAAU,CAAA;AACjD,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA;AAAA;AAC/C,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"gitea.cjs.js","sources":["../../src/actions/gitea.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 { 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, any, 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 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 repoUrl: z =>\n z.string({\n description: 'Repository Location',\n }),\n description: z =>\n z.string({\n description: 'Repository Description',\n }),\n defaultBranch: z =>\n z\n .string({\n description: `Sets the default branch on the repository. The default value is 'main'`,\n })\n .optional(),\n repoVisibility: z =>\n z\n .enum(['private', 'public'], {\n description: `Sets the visibility of the repository. The default value is 'public'.`,\n })\n .optional(),\n gitCommitMessage: z =>\n z\n .string({\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n })\n .optional(),\n gitAuthorName: z =>\n z\n .string({\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n })\n .optional(),\n gitAuthorEmail: z =>\n z\n .string({\n description: `Sets the default author email for the commit.`,\n })\n .optional(),\n sourcePath: z =>\n z\n .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 .optional(),\n signCommit: z =>\n z\n .boolean({\n description: 'Sign commit with configured PGP private key',\n })\n .optional(),\n },\n output: {\n remoteUrl: z =>\n z\n .string({\n description: 'A URL to the repository with the provider',\n })\n .optional(),\n repoContentsUrl: z =>\n z\n .string({\n description: 'A URL to the root of the repository',\n })\n .optional(),\n commitHash: z =>\n z\n .string({\n description: 'The git commit hash of the initial commit',\n })\n .optional(),\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 signCommit,\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\n const signingKey =\n integrationConfig.config.commitSigningKey ??\n config.getOptionalString('scaffolder.defaultCommitSigningKey');\n if (signCommit && !signingKey) {\n throw new Error(\n 'Signing commits is enabled but no signing key is provided in the configuration',\n );\n }\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"],"names":["getGiteaRequestOptions","crypto","createTemplateAction","examples","parseRepoUrl","InputError","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;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QACA,iBAAkB,CAAA,MAAA;AAAA,QAClB;AAAA,UACE,KAAA;AAAA,UACA,IAAA;AAAA,UACA,aAAA;AAAA,UACA;AAAA;AACF,OACF;AAEA,MAAM,MAAA,eAAA,GAAkB,CAAG,EAAA,iBAAA,CAAkB,MAAO,CAAA,OAAO,IAAI,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,YAAA,EAAe,aAAa,CAAA,CAAA,CAAA;AACxG,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,YAAc,EAAA,YAAA,EAAc,UAAU,CAAA;AACjD,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA;AAAA;AAC/C,GACD,CAAA;AACH;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import * as _backstage_plugin_scaffolder_node from '@backstage/plugin-scaffolder-node';
2
- import * as _backstage_types from '@backstage/types';
3
2
  import { Config } from '@backstage/config';
4
3
  import { ScmIntegrationRegistry } from '@backstage/integration';
5
4
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
@@ -15,14 +14,18 @@ declare function createPublishGiteaAction(options: {
15
14
  }): _backstage_plugin_scaffolder_node.TemplateAction<{
16
15
  repoUrl: string;
17
16
  description: string;
18
- defaultBranch?: string;
19
- repoVisibility?: "private" | "public";
20
- gitCommitMessage?: string;
21
- gitAuthorName?: string;
22
- gitAuthorEmail?: string;
23
- sourcePath?: string;
24
- signCommit?: boolean;
25
- }, _backstage_types.JsonObject, "v1">;
17
+ defaultBranch?: string | undefined;
18
+ repoVisibility?: "private" | "public" | undefined;
19
+ gitCommitMessage?: string | undefined;
20
+ gitAuthorName?: string | undefined;
21
+ gitAuthorEmail?: string | undefined;
22
+ sourcePath?: string | undefined;
23
+ signCommit?: boolean | undefined;
24
+ }, {
25
+ remoteUrl?: string | undefined;
26
+ repoContentsUrl?: string | undefined;
27
+ commitHash?: string | undefined;
28
+ }, "v2">;
26
29
 
27
30
  /**
28
31
  * @public
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-gitea",
3
- "version": "0.2.10-next.0",
3
+ "version": "0.2.10-next.1",
4
4
  "description": "The gitea module for @backstage/plugin-scaffolder-backend",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -50,17 +50,17 @@
50
50
  "test": "backstage-cli package test"
51
51
  },
52
52
  "dependencies": {
53
- "@backstage/backend-plugin-api": "1.4.0-next.0",
53
+ "@backstage/backend-plugin-api": "1.4.0-next.1",
54
54
  "@backstage/config": "1.3.2",
55
55
  "@backstage/errors": "1.2.7",
56
56
  "@backstage/integration": "1.17.0",
57
- "@backstage/plugin-scaffolder-node": "0.8.3-next.0",
57
+ "@backstage/plugin-scaffolder-node": "0.8.3-next.1",
58
58
  "yaml": "^2.0.0"
59
59
  },
60
60
  "devDependencies": {
61
- "@backstage/backend-test-utils": "1.6.0-next.0",
62
- "@backstage/cli": "0.32.1",
63
- "@backstage/plugin-scaffolder-node-test-utils": "0.2.3-next.0",
61
+ "@backstage/backend-test-utils": "1.6.0-next.1",
62
+ "@backstage/cli": "0.32.2-next.0",
63
+ "@backstage/plugin-scaffolder-node-test-utils": "0.2.3-next.1",
64
64
  "msw": "^1.0.0"
65
65
  }
66
66
  }