Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.

Commit 802d3eb

Browse files
committed
Refactor: Move build steps into lib/steps and helpers into lib/helpers
Clean up the list of files under lib by grouping them into build steps and helper files. Build steps are the functions that are directly called from the next-on-netlify.js file at root level. Helpers are auxiliary functions used in one of the build steps.
1 parent ee833ce commit 802d3eb

13 files changed

+31
-31
lines changed

lib/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { join } = require("path");
2-
const getNextDistDir = require("./getNextDistDir");
2+
const getNextDistDir = require("./helpers/getNextDistDir");
33

44
// This is where next-on-netlify will place all static files.
55
// The publish key in netlify.toml should point to this folder.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lib/copyNextAssets.js renamed to lib/steps/copyNextAssets.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { join } = require("path");
22
const { copySync } = require("fs-extra");
3-
const { logTitle } = require("./logger");
4-
const { NETLIFY_PUBLISH_PATH, NEXT_DIST_DIR } = require("./config");
3+
const { logTitle } = require("../helpers/logger");
4+
const { NETLIFY_PUBLISH_PATH, NEXT_DIST_DIR } = require("../config");
55

66
// Copy the NextJS' static assets from NextJS distDir to Netlify publish folder.
77
// These need to be available for NextJS to work.

lib/copyPublicFiles.js renamed to lib/steps/copyPublicFiles.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { existsSync, copySync } = require("fs-extra");
2-
const { logTitle } = require("./logger");
3-
const { NETLIFY_PUBLISH_PATH, PUBLIC_PATH } = require("./config");
2+
const { logTitle } = require("../helpers/logger");
3+
const { NETLIFY_PUBLISH_PATH, PUBLIC_PATH } = require("../config");
44

55
// Copy files from public folder to Netlify publish folder
66
const copyPublicFiles = () => {

lib/prepareFolders.js renamed to lib/steps/prepareFolders.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { emptyDirSync } = require("fs-extra");
2-
const { logTitle, log } = require("./logger");
3-
const { NETLIFY_PUBLISH_PATH, NETLIFY_FUNCTIONS_PATH } = require("./config");
2+
const { logTitle, log } = require("../helpers/logger");
3+
const { NETLIFY_PUBLISH_PATH, NETLIFY_FUNCTIONS_PATH } = require("../config");
44

55
// Empty existing publish and functions folders
66
const prepareFolders = () => {

lib/setupHtmlPages.js renamed to lib/steps/setupHtmlPages.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const path = require("path");
22
const { join } = path;
33
const { copySync, existsSync } = require("fs-extra");
4-
const { logTitle, logItem } = require("./logger");
5-
const { NEXT_DIST_DIR, NETLIFY_PUBLISH_PATH } = require("./config");
6-
const allNextJsPages = require("./allNextJsPages");
4+
const { logTitle, logItem } = require("../helpers/logger");
5+
const { NEXT_DIST_DIR, NETLIFY_PUBLISH_PATH } = require("../config");
6+
const allNextJsPages = require("../allNextJsPages");
77

88
// Identify all pages that have been pre-rendered and copy each one to the
99
// Netlify publish directory.

lib/setupRedirects.js renamed to lib/steps/setupRedirects.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ const {
77
const {
88
getSortedRoutes,
99
} = require("@sls-next/lambda-at-edge/dist/lib/sortedRoutes");
10-
const { logTitle, logItem } = require("./logger");
11-
const { NETLIFY_PUBLISH_PATH, CUSTOM_REDIRECTS_PATH } = require("./config");
12-
const allNextJsPages = require("./allNextJsPages");
13-
const getNetlifyRoute = require("./getNetlifyRoute");
14-
const getNetlifyFunctionName = require("./getNetlifyFunctionName");
10+
const { logTitle, logItem } = require("../helpers/logger");
11+
const { NETLIFY_PUBLISH_PATH, CUSTOM_REDIRECTS_PATH } = require("../config");
12+
const allNextJsPages = require("../allNextJsPages");
13+
const getNetlifyRoute = require("../helpers/getNetlifyRoute");
14+
const getNetlifyFunctionName = require("../helpers/getNetlifyFunctionName");
1515

1616
// Setup _redirects file that routes all requests to the appropriate location:
1717
// Either the relevant Netlify function or one of the pre-rendered HTML pages.

0 commit comments

Comments
 (0)