Edits history of script submission #1939 for ' List organization repositories (github)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Github = {
      token: string;
    };
    /**
     * List organization repositories
     * Lists repositories for the specified organization.
    
    **Note:** In order to see the `security_and_analysis` block for a repository you must have admin permissions for the repository or be an owner or security manager for the organization that owns the repository. For more information, see "[Managing security managers in your organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization)."
     */
    export async function main(
      auth: Github,
      org: string,
      type:
        | "all"
        | "public"
        | "private"
        | "forks"
        | "sources"
        | "member"
        | undefined,
      sort: "created" | "updated" | "pushed" | "full_name" | undefined,
      direction: "asc" | "desc" | undefined,
      per_page: string | undefined,
      page: string | undefined
    ) {
      const url = new URL(`https://api.github.com/orgs/${org}/repos`);
      for (const [k, v] of [
        ["type", type],
        ["sort", sort],
        ["direction", direction],
        ["per_page", per_page],
        ["page", page],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      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;
    };
    /**
     * List organization repositories
     * Lists repositories for the specified organization.
    
    **Note:** In order to see the `security_and_analysis` block for a repository you must have admin permissions for the repository or be an owner or security manager for the organization that owns the repository. For more information, see "[Managing security managers in your organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization)."
     */
    export async function main(
      auth: Github,
      org: string,
      type:
        | "all"
        | "public"
        | "private"
        | "forks"
        | "sources"
        | "member"
        | undefined,
      sort: "created" | "updated" | "pushed" | "full_name" | undefined,
      direction: "asc" | "desc" | undefined,
      per_page: string | undefined,
      page: string | undefined
    ) {
      const url = new URL(`https://api.github.com/orgs/${org}/repos`);
      for (const [k, v] of [
        ["type", type],
        ["sort", sort],
        ["direction", direction],
        ["per_page", per_page],
        ["page", page],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 927 days ago