Skip to content

Commit 76026f4

Browse files
committed
test
1 parent 040603b commit 76026f4

File tree

14 files changed

+26
-26
lines changed

14 files changed

+26
-26
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ jobs:
2727
with:
2828
node-version: ${{ matrix.node-version }}
2929
- run: npm ci
30+
- name: Linting
31+
run: npm run format:ci
32+
if: "${{ matrix.node-version == '15.x' }}"
3033
- run: npm test

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const watch = (functionsPath, publishPath) => {
6363
// publishDir: string to path
6464
// watch: { directory: string to path }
6565
// }
66-
//
66+
//
6767

6868
const nextOnNetlify = async (options = {}) => {
6969
const functionsPath = normalize(options.functionsDir || NETLIFY_FUNCTIONS_PATH)

src/lib/helpers/addDefaultLocaleRedirect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const addDefaultLocaleRedirect = async (redirects, route, target, additionalPara
1111
if (!defaultLocale) return
1212

1313
const routePieces = route.split('/')
14-
const routeLocale = routePieces[1]
14+
const [, routeLocale] = routePieces
1515
if (routeLocale === defaultLocale) {
1616
const nakedRoute = route === `/${routeLocale}` ? '/' : route.replace(`/${routeLocale}`, '')
1717
redirects.push({

src/lib/helpers/copyDynamicImportChunks.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ const { join } = require('path')
33
const { copySync, readdirSync } = require('fs-extra')
44

55
const getNextDistDir = require('./getNextDistDir')
6-
const { logTitle } = require("./logger")
7-
6+
const { logTitle } = require('./logger')
87

98
// Check if there are dynamic import chunks and copy to the necessary function dir
109
const copyDynamicImportChunks = async (functionPath) => {

src/lib/helpers/getPrerenderManifest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const transformManifestForI18n = async (manifest) => {
1616
if (isDynamicRoute) {
1717
newRoutes[route] = routes[route]
1818
} else {
19-
const locale = route.split('/')[1]
19+
const [, locale] = route.split('/')
2020
const routeWithoutLocale = `/${route.split('/').slice(2, route.split('/').length).join('/')}`
2121
newRoutes[route] = {
2222
dataRoute: await getDataRouteForRoute(routeWithoutLocale, locale),

src/lib/helpers/handleFileTracking.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const { existsSync, readdirSync, readFileSync, rmdirSync, removeSync, writeFileS
66
const { NETLIFY_PUBLISH_PATH, NETLIFY_FUNCTIONS_PATH } = require('../config')
77

88
const TRACKING_FILE_SEPARATOR = '---'
9+
const getDifference = (before, after) => after.filter((filePath) => !before.includes(filePath))
910

1011
// Clean configured publish and functions folders and track next-on-netlify files
1112
// for future cleans
@@ -49,7 +50,6 @@ const handleFileTracking = ({ functionsPath, publishPath }) => {
4950
isConfiguredFunctionsDir && existsSync(functionsPath) ? readdirSync(functionsPath) : functionsBeforeRun
5051
const publishAfterRun =
5152
isConfiguredPublishDir && existsSync(publishPath) ? readdirSync(publishPath) : publishBeforeRun
52-
const getDifference = (before, after) => after.filter((filePath) => !before.includes(filePath))
5353
const newFunctionsFiles = getDifference(functionsBeforeRun, functionsAfterRun)
5454
const newPublishFiles = getDifference(publishBeforeRun, publishAfterRun)
5555

src/lib/helpers/isRouteInPrerenderManifest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const getPrerenderManifest = require('./getPrerenderManifest')
44
// Return true if the route is defined in the prerender manifest
55
const isRouteInPrerenderManifest = async (route) => {
66
const i18n = await getI18n()
7-
const { defaultLocale, locales } = i18n
7+
const { defaultLocale } = i18n
88
const { routes, dynamicRoutes } = await getPrerenderManifest()
99

1010
const isRouteInManifestWithI18n = () => {
@@ -16,7 +16,7 @@ const isRouteInPrerenderManifest = async (route) => {
1616
return isStaticRoute || route in dynamicRoutes
1717
}
1818

19-
if (i18n.defaultLocale) return isRouteInManifestWithI18n(route)
19+
if (defaultLocale) return isRouteInManifestWithI18n(route)
2020
return route in routes || route in dynamicRoutes
2121
}
2222

src/lib/helpers/setupStaticFileForPage.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@ const getNextDistDir = require('./getNextDistDir')
66

77
// Copy the static asset from pages/inputPath to out_publish/outputPath
88
const setupStaticFileForPage = async ({ inputPath, outputPath = null, publishPath }) => {
9-
// If no outputPath is set, default to the same as inputPath
10-
outputPath = outputPath || inputPath
11-
129
const nextDistDir = await getNextDistDir()
1310

1411
// Perform copy operation
15-
copySync(join(nextDistDir, 'serverless', 'pages', inputPath), join(publishPath, outputPath), {
12+
copySync(join(nextDistDir, 'serverless', 'pages', inputPath), join(publishPath, outputPath || inputPath), {
1613
overwrite: false,
1714
errorOnExist: true,
1815
})

src/lib/pages/getServerSideProps/redirects.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ const getNetlifyFunctionName = require('../../helpers/getNetlifyFunctionName')
66
const getPages = require('./pages')
77

88
// getServerSideProps pages
9-
//
9+
//
1010
// Page params {
1111
// route -> '/ssr', '/ssr/[id]'
1212
// filePath -> 'pages/ssr.js', 'pages/ssr/[id].js'
1313
// }
14-
//
14+
//
1515

1616
const getRedirects = async () => {
1717
const redirects = []

src/lib/pages/getStaticProps/redirects.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ const getNetlifyFunctionName = require('../../helpers/getNetlifyFunctionName')
88
const getPages = require('./pages')
99

1010
// getStaticProps pages
11-
//
11+
//
1212
// Page params {
1313
// route -> '/getStaticProps', '/getStaticProps/3'
1414
// dataRoute -> '/_next/data/{BUILD_ID}/getStaticProps.json', '_next/data/{BUILD_ID}/getStaticProps/3.json'
1515
// srcRoute -> null, /getStaticProps/[id]
1616
// }
17-
//
17+
//
1818
// Page params with i18n {
1919
// route -> '/getStaticProps', '/en/getStaticProps/3'
2020
// dataRoute -> '/_next/data/{BUILD_ID}/getStaticProps.json', '_next/data/{BUILD_ID}/en/getStaticProps/3.json'
2121
// srcRoute -> null, /getStaticProps/[id]
2222
// }
23-
//
24-
//
23+
//
24+
//
2525

2626
// Pages with getStaticProps (without fallback or revalidation) only need
2727
// redirects for i18n and handling preview mode

src/lib/pages/getStaticPropsWithRevalidate/redirects.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ const getNetlifyFunctionName = require('../../helpers/getNetlifyFunctionName')
88
const getPages = require('./pages')
99

1010
// getStaticProps with revalidate pages
11-
//
11+
//
1212
// Page params: {
1313
// route -> '/getStaticProps', '/getStaticProps/3'
1414
// dataRoute -> '/_next/data/{BUILD_ID}/getStaticProps.json', '_next/data/{BUILD_ID}/getStaticProps/3.json'
1515
// srcRoute -> null, /getStaticProps/[id]
1616
// }
17-
//
17+
//
1818
// Page params in i18n {
1919
// route -> '/getStaticProps', '/en/getStaticProps/3'
2020
// dataRoute -> '/_next/data/{BUILD_ID}/getStaticProps.json', '_next/data/{BUILD_ID}/en/getStaticProps/3.json'
2121
// srcRoute -> null, /getStaticProps/[id]
2222
// }
23-
//
23+
//
2424

2525
const getRedirects = async () => {
2626
const redirects = []

src/lib/pages/withoutProps/redirects.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ const isDynamicRoute = require('../../helpers/isDynamicRoute')
55
const getPages = require('./pages')
66

77
// withoutProps pages
8-
//
8+
//
99
// Page params {
1010
// route -> '/about', '/initial/[id]'
1111
// filePath -> 'pages/about.html', 'pages/initial[id].html'
1212
// }
13-
//
13+
//
1414
// Page params in i18n {
1515
// route -> '/en/about', '/fr/initial/[id]'
1616
// filePath -> 'pages/en/about.html', 'pages/fr/initial[id].html'
1717
// }
18-
//
18+
//
1919

2020
const getRedirects = async () => {
2121
const redirects = []

src/lib/steps/setupHeaders.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const { existsSync, readFileSync, writeFileSync } = require('fs-extra')
55
const { CUSTOM_HEADERS_PATH } = require('../config')
66
const { logTitle, logItem } = require('../helpers/logger')
77

8+
const indentNewLine = (s) => `\n ${s}`
9+
810
// Setup _headers file to override specific header rules for next assets
911
const setupHeaders = (publishPath) => {
1012
logTitle('🔀 Setting up headers')
@@ -20,7 +22,6 @@ const setupHeaders = (publishPath) => {
2022
headers.push('# Next-on-Netlify Headers')
2123

2224
// Add rule to override cache control for static chunks
23-
const indentNewLine = (s) => `\n ${s}`
2425
const staticChunkRule = [
2526
`/_next/static/chunks/*`,
2627
indentNewLine(`cache-control: public`),

src/lib/steps/setupRedirects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const setupRedirects = async (publishPath) => {
6060
;[...sortedStaticRedirects, ...sortedDynamicRedirects].forEach((nextRedirect) => {
6161
// One route may map to multiple Netlify routes: e.g., catch-all pages
6262
// require two Netlify routes in the _redirects file
63-
getNetlifyRoutes(nextRedirect.route).map((netlifyRoute) => {
63+
getNetlifyRoutes(nextRedirect.route).forEach((netlifyRoute) => {
6464
const { conditions = [], force = false, statusCode = '200', target } = nextRedirect
6565
const redirectPieces = [netlifyRoute, target, `${statusCode}${force ? '!' : ''}`, conditions.join(' ')]
6666
const redirect = redirectPieces.join(' ').trim()

0 commit comments

Comments
 (0)