All Downloads are FREE. Search and download functionalities are using the official Maven repository.

web.lib.components.api.code-quarkus-github-api.ts Maven / Gradle / Ivy

There is a newer version: 37
Show newest version
import { QuarkusProject } from './model';
import { generateProjectPayload } from './quarkus-project-utils';
import { Api } from './code-quarkus-api';

export async function createGitHubProject(api: Api, project: QuarkusProject) {
  const body = JSON.stringify(generateProjectPayload(project));
  const data = await fetch(`${api.backendUrl}/api/github/project?cn=${api.clientName}`, {
    headers: {
      ...api.requestOptions.headers,
      'Content-Type': 'application/json',
      'GitHub-Code': project.github!.code,
      'GitHub-State': project.github!.state
    },
    method: 'POST',
    body
  }).catch(() => Promise.reject(new Error('Fail to create the GitHub project')));
  if (data.ok)
    return data.json();
  if (data.status === 409) {
    throw new Error(`There is already a project named '${project.metadata.artifactId}' on your GitHub, please retry with a different name (the artifact is the name)...`);
  }
  throw new Error('Failed to create Quarkus project on GitHub');
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy