From b1f1e1cb6af650af126479ff32521d470f23f966 Mon Sep 17 00:00:00 2001 From: Jeff McAffer Date: Thu, 8 Oct 2020 19:20:27 -0700 Subject: [PATCH 1/7] correct for windows slashes in redirect `precompile` --- lib/redirects/precompile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/redirects/precompile.js b/lib/redirects/precompile.js index 97cd39cacba5..736252506726 100755 --- a/lib/redirects/precompile.js +++ b/lib/redirects/precompile.js @@ -85,7 +85,7 @@ module.exports = async function precompileRedirects (pages) { // add a veriation like `/free-pro-team@latest/v3/gists/comments`; // again, we need to do this because all links in content get rewritten if (!developerRoute.startsWith('/enterprise/')) { - const developerRouteWithVersion = path.join(nonEnterpriseDefaultVersion, developerRoute) + const developerRouteWithVersion = slash(path.join(nonEnterpriseDefaultVersion, developerRoute)) const developerRouteWithVersionAndLanguage = `/en/${developerRouteWithVersion}` allRedirects[developerRouteWithVersion] = newPath allRedirects[developerRouteWithVersionAndLanguage] = newPath From 0c7b8777632867ab3bd040e479ad584697be4269 Mon Sep 17 00:00:00 2001 From: Jeff McAffer Date: Thu, 8 Oct 2020 19:57:09 -0700 Subject: [PATCH 2/7] add slash() calls to fix windows paths --- tests/content/lint-files.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/content/lint-files.js b/tests/content/lint-files.js index 7a918b074731..085a392e4e0c 100644 --- a/tests/content/lint-files.js +++ b/tests/content/lint-files.js @@ -1,4 +1,5 @@ const path = require('path') +const slash = require('slash') const fs = require('fs') const walk = require('walk-sync') const matter = require('@github-docs/frontmatter') @@ -109,11 +110,11 @@ describe('lint-files', () => { } const contentMarkdownAbsPaths = walk(contentDir, mdWalkOptions).sort() - const contentMarkdownRelPaths = contentMarkdownAbsPaths.map(p => path.relative(rootDir, p)) + const contentMarkdownRelPaths = contentMarkdownAbsPaths.map(p => slash(path.relative(rootDir, p))) const contentMarkdownTuples = zip(contentMarkdownRelPaths, contentMarkdownAbsPaths) const reusableMarkdownAbsPaths = walk(reusablesDir, mdWalkOptions).sort() - const reusableMarkdownRelPaths = reusableMarkdownAbsPaths.map(p => path.relative(rootDir, p)) + const reusableMarkdownRelPaths = reusableMarkdownAbsPaths.map(p => slash(path.relative(rootDir, p))) const reusableMarkdownTuples = zip(reusableMarkdownRelPaths, reusableMarkdownAbsPaths) describe.each([...contentMarkdownTuples, ...reusableMarkdownTuples])( From d16c1f2087e898f41903b4edc8fc5fde8e0d7393 Mon Sep 17 00:00:00 2001 From: Jeff McAffer Date: Thu, 8 Oct 2020 19:59:15 -0700 Subject: [PATCH 3/7] add missing slash require --- lib/redirects/precompile.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/redirects/precompile.js b/lib/redirects/precompile.js index 736252506726..91f57591efbf 100755 --- a/lib/redirects/precompile.js +++ b/lib/redirects/precompile.js @@ -1,4 +1,5 @@ const path = require('path') +const slash = require('slash') const patterns = require('../patterns') const { latest } = require('../enterprise-server-releases') const getOldPathsFromPermalink = require('../redirects/get-old-paths-from-permalink') From a9112d885d599e3ff57d41aac5bf4d2269dcc8ed Mon Sep 17 00:00:00 2001 From: Jeff McAffer Date: Fri, 9 Oct 2020 08:24:01 -0700 Subject: [PATCH 4/7] fix up redirect paths for Windows --- middleware/archived-enterprise-versions.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/middleware/archived-enterprise-versions.js b/middleware/archived-enterprise-versions.js index 9c0d7f68f650..1c533f3c669a 100644 --- a/middleware/archived-enterprise-versions.js +++ b/middleware/archived-enterprise-versions.js @@ -1,4 +1,5 @@ const path = require('path') +const slash = require('slash') const { latest, deprecated, firstVersionDeprecatedOnNewSite, lastVersionWithoutStubbedRedirectFiles } = require('../lib/enterprise-server-releases') const patterns = require('../lib/patterns') const versionSatisfiesRange = require('../lib/version-satisfies-range') @@ -69,7 +70,7 @@ module.exports = async (req, res, next) => { // for <2.13: /2.12/user/articles/viewing-contributions-on-your-profile function getProxyPath (reqPath, requestedVersion) { const proxyPath = versionSatisfiesRange(requestedVersion, `>=${firstVersionDeprecatedOnNewSite}`) - ? path.join('/', requestedVersion, reqPath) + ? slash(path.join('/', requestedVersion, reqPath)) : reqPath.replace(/^\/enterprise/, '') return `https://github.github.com/help-docs-archived-enterprise-versions${proxyPath}` @@ -97,7 +98,7 @@ function getFallbackRedirects (req, requestedVersion) { // ] .filter(oldPath => oldPath.startsWith('/enterprise') && patterns.enterpriseNoVersion.test(oldPath)) // add in the current language and version - .map(oldPath => path.join('/', req.context.currentLanguage, oldPath.replace('/enterprise/', `/enterprise/${requestedVersion}/`))) + .map(oldPath => slash(path.join('/', req.context.currentLanguage, oldPath.replace('/enterprise/', `/enterprise/${requestedVersion}/`)))) // ignore paths that match the requested path .filter(oldPath => oldPath !== req.path) } From c906187cf7562cf5353085f8863f671314e7ca24 Mon Sep 17 00:00:00 2001 From: Jeff McAffer Date: Fri, 9 Oct 2020 08:52:59 -0700 Subject: [PATCH 5/7] handle windows paths in product definitions --- lib/all-products.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/all-products.js b/lib/all-products.js index 72edac31fd34..09e9d2070aae 100644 --- a/lib/all-products.js +++ b/lib/all-products.js @@ -1,5 +1,6 @@ const fs = require('fs') const path = require('path') +const slash = require('slash') const assert = require('assert') const { difference } = require('lodash') const yaml = require('js-yaml') @@ -23,11 +24,11 @@ const internalProducts = {} sortedProductIds.forEach(productId => { const relPath = productId - const dir = path.join('content', relPath) - const toc = path.join(dir, 'index.md') + const dir = slash(path.join('content', relPath)) + const toc = slash(path.join(dir, 'index.md')) const { data } = frontmatter(fs.readFileSync(toc, 'utf8')) const applicableVersions = getApplicableVersions(data.versions, toc) - const href = path.join('/', applicableVersions[0], productId) + const href = slash(path.join('/', applicableVersions[0], productId)) internalProducts[productId] = { id: productId, From 5242ac5148b6412c4611f77acbcd8410fe0e922f Mon Sep 17 00:00:00 2001 From: Chiedo Date: Fri, 9 Oct 2020 17:26:12 -0400 Subject: [PATCH 6/7] Make windows tests manually triggerable --- .github/workflows/test-windows.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index ec48a099f9e8..596ed37f96ba 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -3,6 +3,7 @@ name: Node.js Tests - Windows on: + workflow_dispatch: schedule: - cron: "50 19 * * *" # once a day at 19:50 UTC / 11:50 PST From d671034573cacb34917db913014f75574ca78377 Mon Sep 17 00:00:00 2001 From: Chiedo Date: Fri, 9 Oct 2020 17:48:15 -0400 Subject: [PATCH 7/7] Enable windows testing on github/docs --- .github/workflows/test-windows.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index 596ed37f96ba..f2d845b30e23 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -45,7 +45,6 @@ jobs: run: npm run check-deps test: - if: github.repository == 'github/docs-internal' runs-on: windows-latest strategy: fail-fast: false