Edits history of script submission #1828 for ' Create an organization repository (github)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Github = {
      token: string;
    };
    /**
     * Create an organization repository
     * Creates a new repository in the specified organization. The authenticated user must be a member of the organization.
    
    **OAuth scope requirements**
    
    When using [OAuth](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/), authorizations must include:
    
    *   `public_repo` scope or `repo` scope to create a public repository. Note: For GitHub AE, use `repo` scope to create an internal repository.
    *   `repo` scope to create a private repository
     */
    export async function main(
      auth: Github,
      org: string,
      body: {
        allow_auto_merge?: boolean;
        allow_merge_commit?: boolean;
        allow_rebase_merge?: boolean;
        allow_squash_merge?: boolean;
        auto_init?: boolean;
        delete_branch_on_merge?: boolean;
        description?: string;
        gitignore_template?: string;
        has_downloads?: boolean;
        has_issues?: boolean;
        has_projects?: boolean;
        has_wiki?: boolean;
        homepage?: string;
        is_template?: boolean;
        license_template?: string;
        merge_commit_message?: "PR_BODY" | "PR_TITLE" | "BLANK";
        merge_commit_title?: "PR_TITLE" | "MERGE_MESSAGE";
        name: string;
        private?: boolean;
        squash_merge_commit_message?: "PR_BODY" | "COMMIT_MESSAGES" | "BLANK";
        squash_merge_commit_title?: "PR_TITLE" | "COMMIT_OR_PR_TITLE";
        team_id?: number;
        use_squash_pr_title_as_default?: boolean;
        visibility?: "public" | "private";
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.github.com/orgs/${org}/repos`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 367 days ago

  • nativets
    type Github = {
      token: string;
    };
    /**
     * Create an organization repository
     * Creates a new repository in the specified organization. The authenticated user must be a member of the organization.
    
    **OAuth scope requirements**
    
    When using [OAuth](https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/), authorizations must include:
    
    *   `public_repo` scope or `repo` scope to create a public repository. Note: For GitHub AE, use `repo` scope to create an internal repository.
    *   `repo` scope to create a private repository
     */
    export async function main(
      auth: Github,
      org: string,
      body: {
        allow_auto_merge?: boolean;
        allow_merge_commit?: boolean;
        allow_rebase_merge?: boolean;
        allow_squash_merge?: boolean;
        auto_init?: boolean;
        delete_branch_on_merge?: boolean;
        description?: string;
        gitignore_template?: string;
        has_downloads?: boolean;
        has_issues?: boolean;
        has_projects?: boolean;
        has_wiki?: boolean;
        homepage?: string;
        is_template?: boolean;
        license_template?: string;
        merge_commit_message?: "PR_BODY" | "PR_TITLE" | "BLANK";
        merge_commit_title?: "PR_TITLE" | "MERGE_MESSAGE";
        name: string;
        private?: boolean;
        squash_merge_commit_message?: "PR_BODY" | "COMMIT_MESSAGES" | "BLANK";
        squash_merge_commit_title?: "PR_TITLE" | "COMMIT_OR_PR_TITLE";
        team_id?: number;
        use_squash_pr_title_as_default?: boolean;
        visibility?: "public" | "private";
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.github.com/orgs/${org}/repos`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 927 days ago