From ca55fd1520df2edaf9a1f535a5ca119980b87e0c Mon Sep 17 00:00:00 2001 From: DRM <128110556+mentios@users.noreply.github.com> Date: Wed, 28 Jun 2023 01:44:36 +0300 Subject: [PATCH] Revert "Repo sync" --- .eslintrc.cjs | 2 +- content/rest/{billing => }/billing.md | 0 content/rest/billing/index.md | 15 ----- .../rest/{code-scanning => }/code-scanning.md | 0 content/rest/code-scanning/index.md | 20 ------- .../codes-of-conduct.md | 0 content/rest/codes-of-conduct/index.md | 18 ------ content/rest/{deploy-keys => }/deploy-keys.md | 0 content/rest/deploy-keys/index.md | 17 ------ content/rest/{emojis => }/emojis.md | 0 content/rest/emojis/index.md | 20 ------- content/rest/{gitignore => }/gitignore.md | 0 content/rest/gitignore/index.md | 18 ------ content/rest/{licenses => }/licenses.md | 0 content/rest/licenses/index.md | 18 ------ content/rest/{markdown => }/markdown.md | 0 content/rest/markdown/index.md | 18 ------ content/rest/{meta => }/meta.md | 0 content/rest/meta/index.md | 21 ------- .../oauth-authorizations.md | 0 content/rest/oauth-authorizations/index.md | 13 ----- content/rest/{packages => }/packages.md | 0 content/rest/packages/index.md | 17 ------ content/rest/{pages => }/pages.md | 0 content/rest/pages/index.md | 20 ------- content/rest/{rate-limit => }/rate-limit.md | 0 content/rest/rate-limit/index.md | 16 ------ content/rest/{reactions => }/reactions.md | 0 content/rest/reactions/index.md | 18 ------ content/rest/{scim => }/scim.md | 0 content/rest/scim/index.md | 15 ----- content/rest/{search => }/search.md | 0 content/rest/search/index.md | 18 ------ .../{secret-scanning => }/secret-scanning.md | 0 content/rest/secret-scanning/index.md | 16 ------ src/rest/scripts/utils/update-markdown.js | 27 ++++++++- src/rest/tests/rendering.js | 55 +------------------ tests/routing/redirects.js | 48 ++++++++++++++++ 38 files changed, 75 insertions(+), 355 deletions(-) rename content/rest/{billing => }/billing.md (100%) delete mode 100644 content/rest/billing/index.md rename content/rest/{code-scanning => }/code-scanning.md (100%) delete mode 100644 content/rest/code-scanning/index.md rename content/rest/{codes-of-conduct => }/codes-of-conduct.md (100%) delete mode 100644 content/rest/codes-of-conduct/index.md rename content/rest/{deploy-keys => }/deploy-keys.md (100%) delete mode 100644 content/rest/deploy-keys/index.md rename content/rest/{emojis => }/emojis.md (100%) delete mode 100644 content/rest/emojis/index.md rename content/rest/{gitignore => }/gitignore.md (100%) delete mode 100644 content/rest/gitignore/index.md rename content/rest/{licenses => }/licenses.md (100%) delete mode 100644 content/rest/licenses/index.md rename content/rest/{markdown => }/markdown.md (100%) delete mode 100644 content/rest/markdown/index.md rename content/rest/{meta => }/meta.md (100%) delete mode 100644 content/rest/meta/index.md rename content/rest/{oauth-authorizations => }/oauth-authorizations.md (100%) delete mode 100644 content/rest/oauth-authorizations/index.md rename content/rest/{packages => }/packages.md (100%) delete mode 100644 content/rest/packages/index.md rename content/rest/{pages => }/pages.md (100%) delete mode 100644 content/rest/pages/index.md rename content/rest/{rate-limit => }/rate-limit.md (100%) delete mode 100644 content/rest/rate-limit/index.md rename content/rest/{reactions => }/reactions.md (100%) delete mode 100644 content/rest/reactions/index.md rename content/rest/{scim => }/scim.md (100%) delete mode 100644 content/rest/scim/index.md rename content/rest/{search => }/search.md (100%) delete mode 100644 content/rest/search/index.md rename content/rest/{secret-scanning => }/secret-scanning.md (100%) delete mode 100644 content/rest/secret-scanning/index.md diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 54d54ca99859..8251ed7fd283 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -13,7 +13,7 @@ module.exports = { babelOptions: { configFile: './.babelrc' }, sourceType: 'module', }, - ignorePatterns: ['tmp/*', '!/.*', '/.next/', 'script/bookmarklets/*', 'rest-api-description/'], + ignorePatterns: ['tmp/*', '!/.*', '/.next/', 'script/bookmarklets/*'], rules: { 'import/no-extraneous-dependencies': ['error', { packageDir: '.' }], }, diff --git a/content/rest/billing/billing.md b/content/rest/billing.md similarity index 100% rename from content/rest/billing/billing.md rename to content/rest/billing.md diff --git a/content/rest/billing/index.md b/content/rest/billing/index.md deleted file mode 100644 index 567cb7d4d4ac..000000000000 --- a/content/rest/billing/index.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: Billing -intro: Use the REST API to get billing information for an enterprise. -topics: - - API -versions: - fpt: '*' - ghec: '*' - ghes: '*' -children: - - /billing -autogenerated: rest ---- - - diff --git a/content/rest/code-scanning/code-scanning.md b/content/rest/code-scanning.md similarity index 100% rename from content/rest/code-scanning/code-scanning.md rename to content/rest/code-scanning.md diff --git a/content/rest/code-scanning/index.md b/content/rest/code-scanning/index.md deleted file mode 100644 index fd21e03dee25..000000000000 --- a/content/rest/code-scanning/index.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: Code Scanning -intro: >- - Use the REST API to retrieve and update {% data - variables.product.prodname_code_scanning %} alerts from a repository. -versions: - fpt: '*' - ghae: '*' - ghec: '*' - ghes: '*' -topics: - - API - - Code scanning - - REST -children: - - /code-scanning -autogenerated: rest ---- - - diff --git a/content/rest/codes-of-conduct/codes-of-conduct.md b/content/rest/codes-of-conduct.md similarity index 100% rename from content/rest/codes-of-conduct/codes-of-conduct.md rename to content/rest/codes-of-conduct.md diff --git a/content/rest/codes-of-conduct/index.md b/content/rest/codes-of-conduct/index.md deleted file mode 100644 index f5f1a51e573c..000000000000 --- a/content/rest/codes-of-conduct/index.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: Codes of conduct -intro: Use the REST API to get information about codes of conduct. -versions: - fpt: '*' - ghae: '*' - ghec: '*' - ghes: '*' -topics: - - API -children: - - /codes-of-conduct -autogenerated: rest ---- - - - - diff --git a/content/rest/deploy-keys/deploy-keys.md b/content/rest/deploy-keys.md similarity index 100% rename from content/rest/deploy-keys/deploy-keys.md rename to content/rest/deploy-keys.md diff --git a/content/rest/deploy-keys/index.md b/content/rest/deploy-keys/index.md deleted file mode 100644 index f263d49dbc69..000000000000 --- a/content/rest/deploy-keys/index.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: Deploy keys -intro: Use the REST API to create and manage deploy keys. -versions: - fpt: '*' - ghae: '*' - ghec: '*' - ghes: '*' -topics: - - API -allowTitleToDifferFromFilename: true -children: - - /deploy-keys -autogenerated: rest ---- - - diff --git a/content/rest/emojis/emojis.md b/content/rest/emojis.md similarity index 100% rename from content/rest/emojis/emojis.md rename to content/rest/emojis.md diff --git a/content/rest/emojis/index.md b/content/rest/emojis/index.md deleted file mode 100644 index 4e4e863e8b99..000000000000 --- a/content/rest/emojis/index.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: Emojis -intro: >- - Use the REST API to list and view all the available emojis to use on {% data - variables.product.product_name %}. -versions: - fpt: '*' - ghae: '*' - ghec: '*' - ghes: '*' -topics: - - API -children: - - /emojis -autogenerated: rest ---- - - - - diff --git a/content/rest/gitignore/gitignore.md b/content/rest/gitignore.md similarity index 100% rename from content/rest/gitignore/gitignore.md rename to content/rest/gitignore.md diff --git a/content/rest/gitignore/index.md b/content/rest/gitignore/index.md deleted file mode 100644 index f0e81e6d927e..000000000000 --- a/content/rest/gitignore/index.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: Gitignore -intro: >- - Use the REST API to get `.gitignore` templates that can be used to ignore - files and directories. -versions: - fpt: '*' - ghae: '*' - ghec: '*' - ghes: '*' -topics: - - API -children: - - /gitignore -autogenerated: rest ---- - - diff --git a/content/rest/licenses/licenses.md b/content/rest/licenses.md similarity index 100% rename from content/rest/licenses/licenses.md rename to content/rest/licenses.md diff --git a/content/rest/licenses/index.md b/content/rest/licenses/index.md deleted file mode 100644 index fdc55c399031..000000000000 --- a/content/rest/licenses/index.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: Licenses -intro: >- - Use the REST API to retrieve popular open source licenses and information - about a particular project's license file. -versions: - fpt: '*' - ghae: '*' - ghec: '*' - ghes: '*' -topics: - - API -children: - - /licenses -autogenerated: rest ---- - - diff --git a/content/rest/markdown/markdown.md b/content/rest/markdown.md similarity index 100% rename from content/rest/markdown/markdown.md rename to content/rest/markdown.md diff --git a/content/rest/markdown/index.md b/content/rest/markdown/index.md deleted file mode 100644 index af008a869969..000000000000 --- a/content/rest/markdown/index.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: Markdown -intro: Use the REST API to render a markdown document as an HTML page or as raw text. -versions: - fpt: '*' - ghae: '*' - ghec: '*' - ghes: '*' -topics: - - API -children: - - /markdown -autogenerated: rest ---- - - - - diff --git a/content/rest/meta/meta.md b/content/rest/meta.md similarity index 100% rename from content/rest/meta/meta.md rename to content/rest/meta.md diff --git a/content/rest/meta/index.md b/content/rest/meta/index.md deleted file mode 100644 index 549cd1bdf0af..000000000000 --- a/content/rest/meta/index.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -title: Meta -intro: >- - Use the REST API to get meta information about {% data - variables.product.product_name %}, including the IP addresses of {% data - variables.product.product_name %} services. -versions: - fpt: '*' - ghae: '*' - ghec: '*' - ghes: '*' -topics: - - API -children: - - /meta -autogenerated: rest ---- - - - - diff --git a/content/rest/oauth-authorizations/oauth-authorizations.md b/content/rest/oauth-authorizations.md similarity index 100% rename from content/rest/oauth-authorizations/oauth-authorizations.md rename to content/rest/oauth-authorizations.md diff --git a/content/rest/oauth-authorizations/index.md b/content/rest/oauth-authorizations/index.md deleted file mode 100644 index bdc3ae597195..000000000000 --- a/content/rest/oauth-authorizations/index.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: OAuth authorizations -intro: Use the REST API to manage the access {% data variables.product.prodname_oauth_app %}s have to your account. -versions: - ghes: '*' -topics: - - API -children: - - /oauth-authorizations -autogenerated: rest ---- - - diff --git a/content/rest/packages/packages.md b/content/rest/packages.md similarity index 100% rename from content/rest/packages/packages.md rename to content/rest/packages.md diff --git a/content/rest/packages/index.md b/content/rest/packages/index.md deleted file mode 100644 index b2fd5c22e454..000000000000 --- a/content/rest/packages/index.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: Packages -intro: >- - Use the REST API to interact with {% data variables.product.prodname_registry - %}. -versions: - fpt: '*' - ghec: '*' - ghes: '>=3.9' -topics: - - API -children: - - /packages -autogenerated: rest ---- - - diff --git a/content/rest/pages/pages.md b/content/rest/pages.md similarity index 100% rename from content/rest/pages/pages.md rename to content/rest/pages.md diff --git a/content/rest/pages/index.md b/content/rest/pages/index.md deleted file mode 100644 index f4b51114304d..000000000000 --- a/content/rest/pages/index.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: Pages -intro: >- - Use the REST API to interact with {% data variables.product.prodname_pages %} - sites and builds. -versions: - fpt: '*' - ghae: '*' - ghec: '*' - ghes: '*' -topics: - - API -children: - - /pages -autogenerated: rest ---- - - - - diff --git a/content/rest/rate-limit/rate-limit.md b/content/rest/rate-limit.md similarity index 100% rename from content/rest/rate-limit/rate-limit.md rename to content/rest/rate-limit.md diff --git a/content/rest/rate-limit/index.md b/content/rest/rate-limit/index.md deleted file mode 100644 index 4c3fd57116e7..000000000000 --- a/content/rest/rate-limit/index.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: Rate limit -intro: Use the REST API to check your current rate limit status. -versions: - fpt: '*' - ghae: '*' - ghec: '*' - ghes: '*' -topics: - - API -children: - - /rate-limit -autogenerated: rest ---- - - diff --git a/content/rest/reactions/reactions.md b/content/rest/reactions.md similarity index 100% rename from content/rest/reactions/reactions.md rename to content/rest/reactions.md diff --git a/content/rest/reactions/index.md b/content/rest/reactions/index.md deleted file mode 100644 index c38af1f8dc07..000000000000 --- a/content/rest/reactions/index.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: Reactions -intro: >- - Use the REST API to interact with reactions on {% data - variables.product.prodname_dotcom %}. -versions: - fpt: '*' - ghae: '*' - ghec: '*' - ghes: '*' -topics: - - API -children: - - /reactions -autogenerated: rest ---- - - diff --git a/content/rest/scim/scim.md b/content/rest/scim.md similarity index 100% rename from content/rest/scim/scim.md rename to content/rest/scim.md diff --git a/content/rest/scim/index.md b/content/rest/scim/index.md deleted file mode 100644 index 2961a53407b7..000000000000 --- a/content/rest/scim/index.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: SCIM -intro: >- - Use the REST API to control and manage your GitHub organization members access - with SCIM. -versions: - ghec: '*' -topics: - - API -children: - - /scim -autogenerated: rest ---- - - diff --git a/content/rest/search/search.md b/content/rest/search.md similarity index 100% rename from content/rest/search/search.md rename to content/rest/search.md diff --git a/content/rest/search/index.md b/content/rest/search/index.md deleted file mode 100644 index 215346359cbb..000000000000 --- a/content/rest/search/index.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: Search -intro: >- - Use the REST API to search for specific items on {% data - variables.product.product_name %}. -versions: - fpt: '*' - ghae: '*' - ghec: '*' - ghes: '*' -topics: - - API -children: - - /search -autogenerated: rest ---- - - diff --git a/content/rest/secret-scanning/secret-scanning.md b/content/rest/secret-scanning.md similarity index 100% rename from content/rest/secret-scanning/secret-scanning.md rename to content/rest/secret-scanning.md diff --git a/content/rest/secret-scanning/index.md b/content/rest/secret-scanning/index.md deleted file mode 100644 index 656002941c8f..000000000000 --- a/content/rest/secret-scanning/index.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: Secret scanning -intro: Use the REST API to retrieve and update secret alerts from a repository. -versions: - fpt: '*' - ghae: '*' - ghec: '*' - ghes: '*' -topics: - - API -children: - - /secret-scanning -autogenerated: rest ---- - - diff --git a/src/rest/scripts/utils/update-markdown.js b/src/rest/scripts/utils/update-markdown.js index 0193c3009839..4d0b97463d7d 100644 --- a/src/rest/scripts/utils/update-markdown.js +++ b/src/rest/scripts/utils/update-markdown.js @@ -85,8 +85,31 @@ async function getDataFrontmatter(dataDirectory, schemaFilename) { async function getMarkdownContent(versions) { const markdownUpdates = {} - for (const [category, subcategoryObject] of Object.entries(versions)) { - const subcategories = Object.keys(subcategoryObject) + for (const category of Object.keys(versions)) { + const subcategories = Object.keys(versions[category]) + // When there is only a single subcategory and the name + // matches the category, this is an override due to a + // subcategory not being defined. In this case, + // the markdown file will be in the content/rest directory. + // The file path will be content/rest/.md + if (subcategories.length === 1 && category === subcategories[0]) { + // this will be a file in the root of the rest directory + const filepath = path.join('content/rest', `${category}.md`) + markdownUpdates[filepath] = { + data: { + title: category, + shortTitle: category, + intro: '', + versions: await convertVersionsToFrontmatter( + versions[category][subcategories[0]].versions + ), + ...frontmatterDefaults, + }, + content: '', + } + continue + } + // The file path will be content/rest//.md for (const subcategory of subcategories) { const filepath = path.join('content/rest', category, `${subcategory}.md`) diff --git a/src/rest/tests/rendering.js b/src/rest/tests/rendering.js index 15f31f358d34..06331b29820d 100644 --- a/src/rest/tests/rendering.js +++ b/src/rest/tests/rendering.js @@ -1,7 +1,7 @@ import { jest, test } from '@jest/globals' import { slug } from 'github-slugger' -import { get, getDOM } from '../../../tests/helpers/e2etest.js' +import { getDOM } from '../../../tests/helpers/e2etest.js' import { isApiVersioned, allVersions } from '../../../lib/all-versions.js' import { getDiffOpenAPIContentRest } from '../scripts/test-open-api-schema.js' import getRest from '#src/rest/lib/index.js' @@ -25,59 +25,6 @@ describe('REST references docs', () => { } }) - // These tests exists because of issue #1960 - test('rest subcategory with fpt in URL', async () => { - for (const category of [ - 'migrations', - 'actions', - 'activity', - 'apps', - 'billing', - 'checks', - 'codes-of-conduct', - 'code-scanning', - 'codespaces', - 'emojis', - 'gists', - 'git', - 'gitignore', - 'interactions', - 'issues', - 'licenses', - 'markdown', - 'meta', - 'orgs', - 'projects', - 'pulls', - 'rate-limit', - 'reactions', - 'repos', - 'scim', - 'search', - 'teams', - 'users', - ]) { - // Without language prefix - { - const res = await get(`/free-pro-team@latest/rest/reference/${category}`) - expect(res.statusCode).toBe(302) - expect( - res.headers.location === `/en/rest/${category}` || - res.headers.location === `/en/rest/${category}/${category}` - ) - } - // With language prefix - { - const res = await get(`/en/free-pro-team@latest/rest/reference/${category}`) - expect(res.statusCode).toBe(301) - expect( - res.headers.location === `/en/rest/${category}` || - res.headers.location === `/en/rest/${category}/${category}` - ) - } - } - }) - test('test the latest version of the OpenAPI schema categories/subcategories to see if it matches the content/rest directory', async () => { const differences = await getDiffOpenAPIContentRest() const errorMessage = formatErrors(differences) diff --git a/tests/routing/redirects.js b/tests/routing/redirects.js index 307defaeba8e..a4aea5354503 100644 --- a/tests/routing/redirects.js +++ b/tests/routing/redirects.js @@ -411,6 +411,54 @@ describe('redirects', () => { }) }) + // These tests exists because of issue #1960 + describe('rest reference redirects with default product', () => { + test('rest subcategory with fpt in URL', async () => { + for (const category of [ + 'migrations', + 'actions', + 'activity', + 'apps', + 'billing', + 'checks', + 'codes-of-conduct', + 'code-scanning', + 'codespaces', + 'emojis', + 'gists', + 'git', + 'gitignore', + 'interactions', + 'issues', + 'licenses', + 'markdown', + 'meta', + 'orgs', + 'projects', + 'pulls', + 'rate-limit', + 'reactions', + 'repos', + 'search', + 'teams', + 'users', + ]) { + // Without language prefix + { + const res = await get(`/free-pro-team@latest/rest/reference/${category}`) + expect(res.statusCode).toBe(302) + expect(res.headers.location).toBe(`/en/rest/${category}`) + } + // With language prefix + { + const res = await get(`/en/free-pro-team@latest/rest/reference/${category}`) + expect(res.statusCode).toBe(301) + expect(res.headers.location).toBe(`/en/rest/${category}`) + } + } + }) + }) + describe('redirects with double-slashes', () => { test('prefix double-slash', async () => { const res = await get(`//en`)