Skip to content

Commit

Permalink
Adds SSG as CLI option and adjusts code to check for string rather th…
Browse files Browse the repository at this point in the history
…an boolean.
  • Loading branch information
ryguyk committed Jan 3, 2024
1 parent 50f5283 commit f54f5c0
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
],
"scripts": {
"setup": "node scripts/yarn/setup.js",
"dev": "yarn build:env-loader && node ./scripts/yarn/dev.js",
"dev": "yarn build:env-loader && node ./scripts/yarn/dev.js --no-SSG",
"build": "yarn build:env-loader && node ./scripts/yarn/build.js",
"build:env-loader": "tsc -b ./packages/env-loader/tsconfig.json",
"build:preview": "yarn build:env-loader && node ./scripts/yarn/build:preview.js",
"build:preview": "yarn build:env-loader && node ./scripts/yarn/build.js --no-SSG",
"build:sitemap": "yarn build:env-loader & node ./scripts/yarn/build:sitemap.js",
"start": "yarn build:env-loader && node ./scripts/yarn/start.js",
"export": "yarn build:env-loader && node ./scripts/yarn/export.js --USE_REDIS",
Expand Down
5 changes: 5 additions & 0 deletions packages/env-loader/src/cli-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ export const getCliOptions = (scriptName: string): EnvVars => {
.option('--USE_REDIS', 'Enable redis')
.option('--REDIS_URL <url>', 'Redis URL')
.option('--SITE_URL <url>', 'Origin used for generated absolute paths')
.option('--SSG', 'Run logic in getStaticPaths to generate all page URLs')
.option(
'--no-SSG',
'Do not run logic in getStaticPaths to generate all page URLs'
)

configureAdditionalHelpText(program, scriptName)

Expand Down
2 changes: 1 addition & 1 deletion scripts/yarn/build.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const { processEnv } = require('env-loader')

processEnv('SSG=true next build')
processEnv('next build')
3 changes: 0 additions & 3 deletions scripts/yarn/build:preview.js

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/yarn/dev.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const { processEnv } = require('env-loader')

processEnv('yarn setup && SSG=false next dev')
processEnv('yarn setup && next dev')
2 changes: 1 addition & 1 deletion scripts/yarn/export.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const { processEnv } = require('env-loader')

processEnv('SSG=true next build && next export')
processEnv('next build && next export')
7 changes: 4 additions & 3 deletions src/lib/drupal/drupalClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ export const drupalClient = new DrupalClient(baseUrl, {
clientSecret: process.env.DRUPAL_CLIENT_SECRET,
},
// Generally use cache for `yarn export` as it generates all pages
cache: process.env.USE_REDIS
? redisCache(createRedisClient(process.env.REDIS_URL))
: null,
cache:
process.env.USE_REDIS === 'true'
? redisCache(createRedisClient(process.env.REDIS_URL))
: null,
previewSecret: process.env.DRUPAL_PREVIEW_SECRET,
})

0 comments on commit f54f5c0

Please sign in to comment.