Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New preset with hybrid SSG/SSR (replaces SSR-only with hybrid rendering modes support) #42

Closed
Closed
Show file tree
Hide file tree
Changes from 162 commits
Commits
Show all changes
203 commits
Select commit Hold shift + click to select a range
cee3e6e
Display APP_VERSION and APP_VERSION_RELEASE in /api/status
Vadorequest Apr 26, 2020
58bca45
Rename preset used in this branch from "v1-ssr-mst-aptd-gcms-lcz-sty"…
Vadorequest Apr 26, 2020
84569a5
Add missing Next.js TS types
Vadorequest Apr 26, 2020
f747475
POC - Implement basic getStaticProps for "index" page (use SSG instea…
Vadorequest Apr 26, 2020
abefe61
Add try/catch block to avoid crash on cookie read (SSG failure at bui…
Vadorequest Apr 26, 2020
f309835
Random attempt trying to fix zeit aliasing
Vadorequest Apr 26, 2020
891a590
Revert - Random attempt trying to fix zeit aliasing
Vadorequest Apr 26, 2020
f9259c2
Add fix for FB as browser
Vadorequest Apr 28, 2020
0c88c2c
Disable outdated-browser-rework - See https://github.com/mikemaccana/…
Vadorequest Apr 30, 2020
4b8900f
Disable SSR entirely (_app) and use SSG with basic i18N + update to n…
Vadorequest Apr 30, 2020
9eacc5f
Remove existing index/terms pages (SSR) and use experimental redirect…
Vadorequest Apr 30, 2020
f328c76
Fix CSR when navigating with Link components
Vadorequest Apr 30, 2020
0c786a8
Add HOC template + TODO
Vadorequest Apr 30, 2020
d62e4b8
Refactor NextLink with I18nLink (automatically handle localisation part)
Vadorequest Apr 30, 2020
20ad826
Use better TS typings for SSG
Vadorequest May 1, 2020
1da06e9
Use unstable_revalidate (disabled)
Vadorequest May 1, 2020
87dc4e6
Use better TS typings for SSG
Vadorequest May 1, 2020
91e5e3a
Refactor SSG duplicated code + SSG doc
Vadorequest May 1, 2020
c839d83
Add Layout (wip)
Vadorequest May 1, 2020
ecbae33
Add getDefaultStaticProps and getDefaultStaticPaths to reduce boilerp…
Vadorequest May 1, 2020
1c643db
Chang Layout implementation, use function as children for improved fl…
Vadorequest May 1, 2020
79b09bf
Misc refactor
Vadorequest May 1, 2020
0cb6a33
Attempt to use API for auto-redirect to localised page, but doesn't w…
Vadorequest May 1, 2020
2adf4f2
Initialise i18nextLocize in Layout
Vadorequest May 1, 2020
4d78b0e
Re-implement _app.render with ApolloProvider and protect against non-…
Vadorequest May 1, 2020
f998d41
Handle 404 edge case
Vadorequest May 1, 2020
969b997
Implement auto language detection based on https://github.com/zeit/ne…
Vadorequest May 1, 2020
6683992
Apply stuff that doesn't change anything locally (maybe it'll work on…
Vadorequest May 1, 2020
799c72a
Redirect link with trailing slash to non-trailing slash (any depth), …
Vadorequest May 1, 2020
5d78e16
Cleanup dead code
Vadorequest May 1, 2020
438cfdc
Add logs for Next.js experimental modules (transparency)
Vadorequest May 2, 2020
4492549
Handle locales such as en-US (redirect + static generation)
Vadorequest May 2, 2020
08175b2
Attempt to fix Zeit "because it would overwrite input file" - See htt…
Vadorequest May 2, 2020
9233e0f
Fix 404 pages served by SSR (temporary fix until code cleanup)
Vadorequest May 3, 2020
736fcd3
Rename "lang" to "locale" in query path - inject both "lang" and "loc…
Vadorequest May 3, 2020
51eb5d5
Use proper terminology "locale" vs "lang" to avoid confusion + fix li…
Vadorequest May 3, 2020
438529e
Add debug logs and doc
Vadorequest May 3, 2020
d6533c4
Refactor Apollo GraphQL and use it with SSG pages (fetch GraphCMS API…
Vadorequest May 3, 2020
17bb489
Implement Layout with Nav/Footer components and apply layout to Terms…
Vadorequest May 3, 2020
e66841e
Refactor I18nLink and extract reusable code into functions + cleanup …
Vadorequest May 3, 2020
7558364
Fix isActive (handles i18n) for nav links + fix nav links (i18n-frien…
Vadorequest May 3, 2020
8a471aa
Remove amplitude eventProperties in Nav, probably from a bad copy/pas…
Vadorequest May 3, 2020
c5a4b99
Misc Nav cleanup
Vadorequest May 3, 2020
a77a776
Change "change locale" feature implementation, now switches between f…
Vadorequest May 3, 2020
0c9387a
Fix false-positive bug due to refactoring (unused file, used for old …
Vadorequest May 3, 2020
73550bc
Fixing alias bugs (#43)
Demmonius May 3, 2020
ff41497
Remove fixed TODO
Vadorequest May 3, 2020
11141e9
Fix Cypress E2E tests (i18n, redirect) + update cypress to 4.5.0
Vadorequest May 3, 2020
4cd3e63
Create store "cookieContext" + enhance LayoutPageProps + make cookies…
Vadorequest May 3, 2020
32d9942
Misc css
Vadorequest May 3, 2020
b560e21
Implement Amplitude analytics (browser-side only)
Vadorequest May 3, 2020
84ac270
Refactor LayoutSSG > PageLayout
Vadorequest May 3, 2020
cbca158
Mute "Warning: Text content did not match"
Vadorequest May 3, 2020
d8588b3
Massive refactor of Layout (split in 3 components) + logs cleaning (a…
Vadorequest May 3, 2020
5b1a670
Refactor Head component and allow to define HeadProps from pages (SEO…
Vadorequest May 3, 2020
998f51e
Clarify max-age for translations
Vadorequest May 3, 2020
3cde65a
Track page displayed (Amplitude analytics)
Vadorequest May 3, 2020
4a2ff62
Rename DEFAULT_LANG into DEFAULT_LOCALE + handle cases where the loca…
Vadorequest May 4, 2020
d57001c
Add 404 page (doesn't support i18n)
Vadorequest May 4, 2020
33b7f67
Disable getStaticPaths for 404 page (crash whole app)
Vadorequest May 4, 2020
bbcea7c
Remove @zeit/next-css package, built-in with Next since 9.2 - See htt…
Vadorequest May 5, 2020
ad20b35
Misc TS type
Vadorequest May 5, 2020
7832f1a
Rename LayoutPageProps > PageLayoutProps (consistency) and associated…
Vadorequest May 5, 2020
427f936
Refactor CSS global styles into UniversalGlobalStyles (code quality)
Vadorequest May 5, 2020
e09eeb3
Refactor Nav/Footer using customerContext and i18nContext stores to a…
Vadorequest May 5, 2020
f169e46
Rename cookieContext to sessionContext
Vadorequest May 5, 2020
4d0e7fa
Moved /examples to /[locale]/examples - TODO this page crash with "to…
Vadorequest May 5, 2020
87163af
Refactor I18nLink to use i18nContext instead of props
Vadorequest May 5, 2020
2a39f8b
Restore HomePage content (from SSR version)
Vadorequest May 5, 2020
28c790d
Restore TermsPage content (from SSR version)
Vadorequest May 5, 2020
1d150bc
Override getStaticProps in terms/examples pages to fetch page-specifi…
Vadorequest May 5, 2020
6ed6a8a
Re-enable "Text content did not match" warning and use "DisplayOnBrow…
Vadorequest May 5, 2020
5041e78
Remove TODO, add doc
Vadorequest May 5, 2020
34c44cf
Add useHasMounted utility
Vadorequest May 5, 2020
b1fec35
Add useHasMounted utility
Vadorequest May 5, 2020
46cfb95
Avoid wrapping children of DisplayOnBrowserMount in a div (simplifies…
Vadorequest May 5, 2020
8201c63
Typo
Vadorequest May 5, 2020
38131a2
Refactor i18n (extract types) + Add link alternate for hreflang as Go…
Vadorequest May 5, 2020
8c6afde
Refactor withApollo HOC, inspired by https://github.com/zeit/next.js/…
Vadorequest May 6, 2020
a9451ac
Remove usage of ApolloProvider in _app (avoid disabling auto static o…
Vadorequest May 6, 2020
21d773f
Misc add TS types
Vadorequest May 6, 2020
a11cd17
Rename apolloStaticCache to apolloState (use same name for SSG and SSR)
Vadorequest May 6, 2020
410522a
Misc cleanup
Vadorequest May 6, 2020
166c719
Add /products page (SSR) + make apollo work nicely for both SSR and SSG
Vadorequest May 6, 2020
1513b35
Add link to /products page
Vadorequest May 6, 2020
eceb3a2
Fix E2E
Vadorequest May 6, 2020
0bc9215
Display draft products at /products to allow manual testing from visi…
Vadorequest May 6, 2020
5ab8ae1
Cleanup TS types
Vadorequest May 6, 2020
75264b3
Massive refactoring of the core (App vs Layout)
Vadorequest May 6, 2020
b0d08f8
Documentation
Vadorequest May 6, 2020
6f2d742
Refactoring Bootstrap
Vadorequest May 6, 2020
cdb52ec
More TS types
Vadorequest May 6, 2020
81f67fd
Rewrite SSR /products page to avoid crashing on CSR, now use getServe…
Vadorequest May 6, 2020
ea28688
Cleanup types in Layout and add doc + make some TS types more generic
Vadorequest May 6, 2020
618b336
Capitalise GetCommonServerSidePropsResults (convention)
Vadorequest May 7, 2020
b7055a0
Doc
Vadorequest May 7, 2020
ed5eb51
Rename defaultLocales into i18nTranslations
Vadorequest May 7, 2020
331c9d0
Fix infinite loop react rendering during CSR by using a "globalI18nex…
Vadorequest May 7, 2020
669e929
Doc regarding proptypes vs typescript types
Vadorequest May 7, 2020
482bab0
Add __N_SSP
Vadorequest May 7, 2020
1fc3367
Use DDD for /components - See https://css-tricks.com/domain-driven-de…
Vadorequest May 7, 2020
d69e6e0
Rename hoc folder to hocs
Vadorequest May 7, 2020
40d7b8e
Use DDD for /types (TS types) - See https://css-tricks.com/domain-dri…
Vadorequest May 7, 2020
f1718a8
Use DDD for /utils - See https://css-tricks.com/domain-driven-design-…
Vadorequest May 7, 2020
a80d3c2
Add info about which i18n plugins are used
Vadorequest May 7, 2020
7ac2100
Remove deprecated i18next-node-locize-backend and upgrade i18next-loc…
Vadorequest May 7, 2020
e06f924
Enable locize saveMissing feature in staging for debug
Vadorequest May 8, 2020
4c03a47
Enable i18n debug on !production
Vadorequest May 8, 2020
6077bb2
Misc i18n doc
Vadorequest May 8, 2020
1b8c684
Fix debug mode
Vadorequest May 8, 2020
e5d5098
Use locize-lastused instead of locize-node-lastused (now deprecated) …
Vadorequest May 8, 2020
b16b8ff
Misc TS types i18n
Vadorequest May 8, 2020
12fd045
Add faker i18n key for testing on staging
Vadorequest May 8, 2020
22bd7be
Revert to only save missing in development env ("saveMissing" issue w…
Vadorequest May 8, 2020
dfa062e
Misc doc
Vadorequest May 8, 2020
99566f7
Revert "faker" test
Vadorequest May 8, 2020
8f69e2e
Rename nrn-locize-api-key to nrn-locize-api-key-staging and remove it…
Vadorequest May 8, 2020
5005da8
Rename sessionContext to userSessionContext and remove cookiesManager…
Vadorequest May 8, 2020
a7307e0
Attempt to fix https://github.com/locize/locize-lastused/issues/4 (ES…
Vadorequest May 8, 2020
ebecf50
Refactor use of userSessionContext and use useUserSession hook instead
Vadorequest May 8, 2020
7717d8d
Refactor MultiversalAppBootstrap, handles browser/server different re…
Vadorequest May 8, 2020
3b4a583
Improve DisplayOnBrowserMount by allowing universal code to behave di…
Vadorequest May 8, 2020
c2dbf88
Misc doc
Vadorequest May 8, 2020
807f4ca
Refactor use of i18nContext and use useI18n hook instead
Vadorequest May 8, 2020
1da7d17
misc doc
Vadorequest May 8, 2020
5f66aaf
Ignore noisy warning
Vadorequest May 8, 2020
a0a961f
Fix 404 page (wasn't displaying any content when language was mistake…
Vadorequest May 9, 2020
79a4bd7
Cleanup TS prop types
Vadorequest May 9, 2020
ef195a7
Misc code cleanup
Vadorequest May 9, 2020
d120423
Rename UniversalSSGPageProps > SSGPageProps and UniversalSSRPageProps…
Vadorequest May 9, 2020
8b1daa4
Add example doc
Vadorequest May 9, 2020
bf63645
Refactored TS pageProps types, fixed a few typings mistakes
Vadorequest May 9, 2020
c7a010e
Improve pageProps types, and add TS helper to avoid struggling with p…
Vadorequest May 9, 2020
771941d
Rename PageProps to SoftPageProps and avoid using it when we know wha…
Vadorequest May 9, 2020
67ddeb6
Refactor _document and remove complex business logic that isn't neede…
Vadorequest May 9, 2020
6df8375
Add more css class-based variables in body
Vadorequest May 9, 2020
fe705b6
Rename withApollo "ssr" option to "useGetInitialProps" to avoid peopl…
Vadorequest May 9, 2020
434e168
Doc - Add note regarding target: severless
Vadorequest May 13, 2020
e3486d2
Refactoring errors handling (fixes some error handling bugs and depre…
Vadorequest May 15, 2020
dcf369d
Remove unused error handling in _app (errors in _app are properly cau…
Vadorequest May 15, 2020
97e8251
Oops - Local testing got pushed
Vadorequest May 15, 2020
0d93cac
Simplify error debug UI
Vadorequest May 15, 2020
2d15936
Refactor _app and use Functional Component instead of class
Vadorequest May 15, 2020
116d7c0
Misc
Vadorequest May 15, 2020
92099a8
Use node v12.x for CI
Vadorequest May 15, 2020
f3d362a
Use router instead of window.href to let Next.js refresh the page wit…
Vadorequest May 15, 2020
7284415
Cleanup hook usage
Vadorequest May 15, 2020
e502def
Add router to DOM for quick testing
Vadorequest May 15, 2020
f3c0487
Attempt to use router instance instead of singleton (unlikely to solv…
Vadorequest May 15, 2020
d38a999
Fix routing (?)
Vadorequest May 15, 2020
58cd8a6
Fix TS type (forgot to add MultiversalAppBootstrapPageProps which are…
Vadorequest May 15, 2020
b52802b
Fix TS types + add better documentation
Vadorequest May 15, 2020
fad1e2d
Attempt to avoid redirects when an asset isn't found
Vadorequest May 15, 2020
173578d
Update Next.js framework to v9.4.0 (gone through some issues with web…
Vadorequest May 15, 2020
386ac66
Fix i18n language refresh when changing language from the client side…
Vadorequest May 15, 2020
c3c7a4e
Fix webpack custom env vars based on buildId (APP_VERSION_RELEASE) - …
Vadorequest May 15, 2020
a805751
Attempt to fix TypeError: Cannot set property 'process.env.APP_RELEAS…
Vadorequest May 15, 2020
7e38b08
Remove isomorphic-unfetch dep - See https://nextjs.org/blog/next-9-4#…
Vadorequest May 15, 2020
2a29911
Track web-vitals-metrics using Amplitude, by batch of 5 and 2 metrics…
Vadorequest May 15, 2020
d09ff7a
Small improvement + count bugfix
Vadorequest May 15, 2020
ead7777
Misc doc
Vadorequest May 16, 2020
18fbc6d
Avoid tests being deployed as Vercel Serverless Functions (increases …
Vadorequest May 16, 2020
151b8a6
Remove unused font
Vadorequest May 16, 2020
1f48e47
Disable unused css (animate.css)
Vadorequest May 16, 2020
886544c
Misc remove useless recompose/compose usage
Vadorequest May 16, 2020
40e7edc
Always add img "alt" even if it's meaningless (fallback from "alt" to…
Vadorequest May 16, 2020
163c4aa
Use WebP or JPEX XR whenever possible
Vadorequest May 16, 2020
6482cbf
Use rel=noopener with Logo for security/perfs (good practice)
Vadorequest May 16, 2020
c9970d9
Fix tests and snapshots
Vadorequest May 16, 2020
135b029
Load fonts async properly (avoid render-blocking)
Vadorequest May 16, 2020
285957e
Track NRN_PRESET with amplitude
Vadorequest May 16, 2020
1cfd411
Fix typo
Vadorequest May 17, 2020
c9a29b0
Upgrade next to 9.4.1 (patch)
Vadorequest May 18, 2020
ce9fb89
Upgrade @apollo/react-ssr to 3.1.5 (patch) - Should fix react warning…
Vadorequest May 18, 2020
1e6493a
Upgrade @now/node to 1.6.1 (minor)
Vadorequest May 18, 2020
11ca751
Upgrade Sentry to 5.15.5 (patch)
Vadorequest May 18, 2020
6ef3204
Upgrade Amplitude to 6.2 (MAJOR)
Vadorequest May 18, 2020
67d9cbf
Upgrade TypeScript to 3.9.2 (minor) - Perfs improvements https://www.…
Vadorequest May 18, 2020
fad6aef
Upgrade Jest to 26.0.1 (MAJOR) and related packages
Vadorequest May 18, 2020
f46cf79
Fix TS error due to recent upgrade
Vadorequest May 18, 2020
0df98ef
Upgrade EsLint to 7.0.0 (MAJOR) + all eslint-related deps
Vadorequest May 18, 2020
5021ed1
Reduce eslint noise
Vadorequest May 18, 2020
d0c4263
Upgrade TS types (definitelyTyped)
Vadorequest May 18, 2020
1a4ff80
Upgrade various devDeps packages
Vadorequest May 18, 2020
4877602
Upgrade Animate to 4.1.0 (MAJOR - BC)
Vadorequest May 18, 2020
c2c86cb
Rename animate classes using animate__ prefix - See https://animate.s…
Vadorequest May 18, 2020
778a442
Upgrade bootstrap to 4.5.0 (minor)
Vadorequest May 18, 2020
33ba256
Upgrade all Apollo-related deps
Vadorequest May 18, 2020
918ab34
Upgrade all i18next/locize-related deps
Vadorequest May 18, 2020
2a00ead
Add @next/bundle-analyzer and "next:bundle" command to help analyse t…
Vadorequest May 18, 2020
a58252c
Misc doc
Vadorequest May 18, 2020
b26c892
Improve I18nLink component, add more options and simplifies usage
Vadorequest May 18, 2020
b45cb66
Add ExternalLink component to simplify usage of external links (SEO, …
Vadorequest May 18, 2020
df4d6f5
Add component template to get started quickly
Vadorequest May 18, 2020
902769e
Add TS @types for bootstrap
Vadorequest May 19, 2020
83f893c
Add image optimisation example
Vadorequest May 20, 2020
555b44b
Demo v2 - Full rework of the demo examples (#52)
Vadorequest May 27, 2020
ec66fef
Don't init Sentry if SENTRY_DSN isn't defined
Vadorequest May 28, 2020
620c8c9
Add doc about native Next.js optimisations
Vadorequest May 28, 2020
916e2a2
Update Next to v9.4.4
Vadorequest May 28, 2020
d46366f
Add indexes for folders (avoid directory listing) + improve sidebar p…
Vadorequest May 28, 2020
0d0714c
Misc reorder SSG pages (getStaticPaths before getStaticProps) for con…
Vadorequest May 28, 2020
e370bf5
Add warning regarding unexpected 404 behaviour when using CSR links
Vadorequest May 28, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.build.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ NODE_ENV=development
APP_STAGE=development

# The NRN preset used for the demo
NRN_PRESET=v1-ssr-mst-aptd-gcms-lcz-sty
NRN_PRESET=v1-hyb-mst-aptd-gcms-lcz-sty

# The customer that is being deployed
CUSTOMER_REF=customer1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-zeit-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:
# Configures the deployment environment, install dependencies (like node, npm, etc.) that are requirements for the upcoming jobs
# Ex: Necessary to run `yarn deploy`
setup-environment:
name: Setup deployment environment (Ubuntu 18.04 - Node 10.x)
name: Setup deployment environment (Ubuntu 18.04 - Node 12.x)
runs-on: ubuntu-18.04
steps:
- name: Installing node.js
uses: actions/setup-node@v1 # Used to install node environment - XXX https://github.com/actions/setup-node
with:
node-version: '10.x' # Use the same node.js version as the one Zeit's uses (currently node10.x)
node-version: '12.x' # Use the same node.js version as the one Zeit's uses (currently node12.x)

# Starts a Zeit deployment, using the production configuration file of the default institution
# The default institution is the one defined in the `now.json` file (which is a symlink to the actual file)
Expand Down
24 changes: 15 additions & 9 deletions .github/workflows/deploy-zeit-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:
# Configures the deployment environment, install dependencies (like node, npm, etc.) that are requirements for the upcoming jobs
# Ex: Necessary to run `yarn deploy`
setup-environment:
name: Setup deployment environment (Ubuntu 18.04 - Node 10.x)
name: Setup deployment environment (Ubuntu 18.04 - Node 12.x)
runs-on: ubuntu-18.04
steps:
- name: Installing node.js
uses: actions/setup-node@v1 # Used to install node environment - XXX https://github.com/actions/setup-node
with:
node-version: '10.x' # Use the same node.js version as the one Zeit's uses (currently node10.x)
node-version: '12.x' # Use the same node.js version as the one Zeit's uses (currently node12.x)

# Starts a Zeit deployment, using the staging configuration file of the default institution
# The default institution is the one defined in the `now.json` file (which is a symlink to the actual file)
Expand All @@ -46,13 +46,19 @@ jobs:
else
ZEIT_DEPLOYMENT_ALIAS=$(cat now.json | jq -r '.name')-${CURRENT_BRANCH##*/}
fi

# Zeit alias only allows 53 characters in the domain name, so we only keep the first 46 characters (because Zeit needs 7 chars for ".now.sh" at the end of the domain name)
# Also, in order to remove forbidden characters, we create a sequence from ascii numbers using ranges of numbers (we forbid characters by using `seq X Y` and we add others by using ';').
# All special characters are converted to `-` (using `tr $0 $1` where $0 is replaced by $1), and only 0-9 and a-Z chars are kept intact.
# We then use `awk` to convert "ascii numbers" back into actual characters.
# You can find the numbers equivalence by tapping `man ascii` and look at the "decimal" set.
ZEIT_DEPLOYMENT_ALIAS=$(echo $ZEIT_DEPLOYMENT_ALIAS | head -c 46 | tr "`(seq 0 47 ; seq 58 64 ; seq 91 96 && seq 123 127) | awk '{printf("%c",$1)}'`" -).now.sh

# Zeit alias only allows 53 characters in the domain name, so we only keep the first 45 (45 = 53 - 7 - 1) characters (because Zeit needs 7 chars for ".now.sh" at the end of the domain name, and count starts at 1, not 0)
# Also, in order to remove forbidden characters, we transform every characters which are not a "alnum" and \n or \r into '-'

ZEIT_DEPLOYMENT_ALIAS=$(echo $ZEIT_DEPLOYMENT_ALIAS | head -c 45 | tr -c '[:alnum:]\r\n' - | tr '[:upper:]' '[:lower:]')

# Recursively remove any trailing dash ('-')
while [[ "$ZEIT_DEPLOYMENT_ALIAS" == *- ]]
do
ZEIT_DEPLOYMENT_ALIAS=${ZEIT_DEPLOYMENT_ALIAS::-1}
done

ZEIT_DEPLOYMENT_ALIAS=$ZEIT_DEPLOYMENT_ALIAS.now.sh
echo "::set-env name=ZEIT_DEPLOYMENT_ALIAS::https://$ZEIT_DEPLOYMENT_ALIAS"

npx now alias $ZEIT_DEPLOYMENT_URL https://$ZEIT_DEPLOYMENT_ALIAS --token $ZEIT_TOKEN
Expand Down
4 changes: 4 additions & 0 deletions .nowignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ README.md
schema.graphql
yarn.lock
yarn-error.log

# Avoid tests being deployed as Vercel Serverless Functions (increases bundle size, and count towards limits)
src/pages/api/*.test.ts
src/pages/api/**/*.test.ts
2 changes: 1 addition & 1 deletion cypress/config-customer1.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"baseUrl": "https://nrn-v1-ssr-mst-aptd-gcms-lcz-sty-c1.now.sh/",
"baseUrl": "https://nrn-v1-hyb-mst-aptd-gcms-lcz-sty-c1.now.sh/",
"projectId": "4dvdog",
"screenshotsFolder": "cypress/screenshots/customer1",
"videosFolder": "cypress/videos/customer1",
Expand Down
2 changes: 1 addition & 1 deletion cypress/config-customer2.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"baseUrl": "https://nrn-v1-ssr-mst-aptd-gcms-lcz-sty-c2.now.sh/",
"baseUrl": "https://nrn-v1-hyb-mst-aptd-gcms-lcz-sty-c2.now.sh/",
"projectId": "4dvdog",
"screenshotsFolder": "cypress/screenshots/customer2",
"videosFolder": "cypress/videos/customer2",
Expand Down
8 changes: 4 additions & 4 deletions cypress/integration/app/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ describe('Index page', () => {
/**
* Navbar section
*/
it('should have 5 links in the navigation bar', () => {
cy.get('#nav a.nav-link').should('have.length', 5);
it('should have 6 links in the navigation bar', () => {
cy.get('#nav a.nav-link').should('have.length', 6);
});

it('should have a link in the navbar that redirects to the examples page', () => {
cy.url().should('eq', `${baseUrl}/`);
cy.url().should('eq', `${baseUrl}/en`);
cy.get('#nav-link-examples')
.should('have.text', 'Examples')
.click();
cy.url().should('eq', `${baseUrl}/examples`);
cy.url().should('eq', `${baseUrl}/en/examples`);
});
});
66 changes: 59 additions & 7 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
const withSourceMaps = require('@zeit/next-source-maps')();
const withCSS = require('@zeit/next-css'); // Allows to import ".css" files, like bootstrap.css
const packageJson = require('./package');
const date = new Date();
const i18nConfig = require('./src/i18nConfig');
const supportedLocales = i18nConfig.supportedLocales.map((supportedLocale) => {
return supportedLocale.name;
});
const publicBasePaths = ['robots', 'static', 'favicon.ico']; // All items (folders, files) under /public directory should be added there, to avoid redirection when an asset isn't found
const noRedirectBasePaths = [...supportedLocales, ...publicBasePaths]; // Will disable url rewrite for those items (should contain all supported languages and all public base paths)

console.debug(`Building Next with NODE_ENV="${process.env.NODE_ENV}" APP_STAGE="${process.env.APP_STAGE}" for CUSTOMER_REF="${process.env.CUSTOMER_REF}"`);

module.exports = withCSS(withSourceMaps({
module.exports = withSourceMaps({
// target: 'serverless', // Automatically enabled on Vercel, you may need to manually opt-in if you're not using Vercel - See https://nextjs.org/docs/api-reference/next.config.js/build-target#serverless-target
env: {
// XXX Duplication of the environment variables, this is only used locally (See https://github.com/zeit/next.js#build-time-configuration)
// while now.json:build:env will be used on the Now platform (See https://zeit.co/docs/v2/build-step/#providing-environment-variables)
Expand All @@ -26,12 +32,58 @@ module.exports = withCSS(withSourceMaps({
APP_VERSION: packageJson.version,
UNLY_SIMPLE_LOGGER_ENV: process.env.APP_STAGE, // Used by @unly/utils-simple-logger - Fix missing staging logs because it believes we're in production
},
experimental: {
redirects() {
const redirects = [
{
// Redirect root link with trailing slash to non-trailing slash, avoids 404 - See https://github.com/zeit/next.js/discussions/10651#discussioncomment-8270
source: '/:locale/',
destination: '/:locale',
permanent: process.env.APP_STAGE !== 'development', // Do not use permanent redirect locally to avoid browser caching when working on it
},
{
// Redirect link with trailing slash to non-trailing slash (any depth), avoids 404 - See https://github.com/zeit/next.js/discussions/10651#discussioncomment-8270
source: '/:locale/:path*/',
destination: '/:locale/:path*',
permanent: process.env.APP_STAGE !== 'development', // Do not use permanent redirect locally to avoid browser caching when working on it
},
];

if (process.env.APP_STAGE === 'development') {
console.info('Using experimental redirects:', redirects);
}

return redirects;
},
rewrites() {
const rewrites = [
{
// XXX Doesn't work locally (maybe because of rewrites), but works online
source: '/',
destination: '/api/autoRedirectToLocalisedPage',
Vadorequest marked this conversation as resolved.
Show resolved Hide resolved
},
{
source: `/:locale((?!${noRedirectBasePaths.join('|')})[^/]+)(.*)`,
destination: '/api/autoRedirectToLocalisedPage',
},
];

if (process.env.APP_STAGE === 'development') {
console.info('Using experimental rewrites:', rewrites);
}

return rewrites;
},
},
webpack: (config, { isServer, buildId }) => {
const APP_VERSION_RELEASE = `${packageJson.version}_${buildId}`;

// Dynamically add some "env" variables that will be replaced during the build
config.plugins[1].definitions['process.env.APP_RELEASE'] = JSON.stringify(buildId);
config.plugins[1].definitions['process.env.APP_VERSION_RELEASE'] = JSON.stringify(APP_VERSION_RELEASE);
config.plugins.map((plugin, i) => {
if (plugin.definitions) { // If it has a "definitions" key, then we consider it's the DefinePlugin where ENV vars are stored
// Dynamically add some "env" variables that will be replaced during the build in "DefinePlugin"
plugin.definitions['process.env.APP_RELEASE'] = JSON.stringify(buildId);
plugin.definitions['process.env.APP_VERSION_RELEASE'] = JSON.stringify(APP_VERSION_RELEASE);
}
});

if (isServer) { // Trick to only log once
console.debug(`[webpack] Building release "${APP_VERSION_RELEASE}"`);
Expand Down Expand Up @@ -64,4 +116,4 @@ module.exports = withCSS(withSourceMaps({
return config;
},
poweredByHeader: 'NRN - With love',
}));
});
6 changes: 3 additions & 3 deletions now.customer1.production.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"version": 2,
"name": "nrn-v1-ssr-mst-aptd-gcms-lcz-sty-c1",
"name": "nrn-v1-hyb-mst-aptd-gcms-lcz-sty-c1",
"scope": "team_qnVfSEVc2WwmOE1OYhZr4VST",
"env": {},
"build": {
"env": {
"APP_STAGE": "production",
"NRN_PRESET": "v1-ssr-mst-aptd-gcms-lcz-sty",
"NRN_PRESET": "v1-hyb-mst-aptd-gcms-lcz-sty",
"CUSTOMER_REF": "customer1",
"GRAPHQL_API_ENDPOINT": "https://api-euwest.graphcms.com/v1/ck73ixhlv09yt01dv2ga1bkbp/master",
"GRAPHQL_API_KEY": "@nrn-graphql-api-key",
"LOCIZE_PROJECT_ID": "@nrn-locize-project-id",
"LOCIZE_API_KEY": "@nrn-locize-api-key",
"LOCIZE_API_KEY": "The Locize API Key shouldn't be used in production (see https://github.com/locize/i18next-locize-backend#backend-options) because it's related to development-only features, and it's sensitive.",
"AMPLITUDE_API_KEY": "@nrn-amplitude-api-key-production",
"SENTRY_DSN": "@nrn-sentry-dsn"
}
Expand Down
6 changes: 3 additions & 3 deletions now.customer1.staging.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"version": 2,
"name": "nrn-v1-ssr-mst-aptd-gcms-lcz-sty-c1",
"name": "nrn-v1-hyb-mst-aptd-gcms-lcz-sty-c1",
"scope": "team_qnVfSEVc2WwmOE1OYhZr4VST",
"env": {},
"build": {
"env": {
"APP_STAGE": "staging",
"NRN_PRESET": "v1-ssr-mst-aptd-gcms-lcz-sty",
"NRN_PRESET": "v1-hyb-mst-aptd-gcms-lcz-sty",
"CUSTOMER_REF": "customer1",
"GRAPHQL_API_ENDPOINT": "https://api-euwest.graphcms.com/v1/ck73ixhlv09yt01dv2ga1bkbp/master",
"GRAPHQL_API_KEY": "@nrn-graphql-api-key",
"LOCIZE_PROJECT_ID": "@nrn-locize-project-id",
"LOCIZE_API_KEY": "@nrn-locize-api-key",
"LOCIZE_API_KEY": "@nrn-locize-api-key-staging",
"AMPLITUDE_API_KEY": "@nrn-amplitude-api-key-staging",
"SENTRY_DSN": "@nrn-sentry-dsn"
}
Expand Down
6 changes: 3 additions & 3 deletions now.customer2.production.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"version": 2,
"name": "nrn-v1-ssr-mst-aptd-gcms-lcz-sty-c2",
"name": "nrn-v1-hyb-mst-aptd-gcms-lcz-sty-c2",
"scope": "team_qnVfSEVc2WwmOE1OYhZr4VST",
"env": {},
"build": {
"env": {
"APP_STAGE": "production",
"NRN_PRESET": "v1-ssr-mst-aptd-gcms-lcz-sty",
"NRN_PRESET": "v1-hyb-mst-aptd-gcms-lcz-sty",
"CUSTOMER_REF": "customer2",
"GRAPHQL_API_ENDPOINT": "https://api-euwest.graphcms.com/v1/ck73ixhlv09yt01dv2ga1bkbp/master",
"GRAPHQL_API_KEY": "@nrn-graphql-api-key",
"LOCIZE_PROJECT_ID": "@nrn-locize-project-id",
"LOCIZE_API_KEY": "@nrn-locize-api-key",
"LOCIZE_API_KEY": "The Locize API Key shouldn't be used in production (see https://github.com/locize/i18next-locize-backend#backend-options) because it's related to development-only features, and it's sensitive.",
"AMPLITUDE_API_KEY": "@nrn-amplitude-api-key-production",
"SENTRY_DSN": "@nrn-sentry-dsn"
}
Expand Down
6 changes: 3 additions & 3 deletions now.customer2.staging.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"version": 2,
"name": "nrn-v1-ssr-mst-aptd-gcms-lcz-sty-c2",
"name": "nrn-v1-hyb-mst-aptd-gcms-lcz-sty-c2",
"scope": "team_qnVfSEVc2WwmOE1OYhZr4VST",
"env": {},
"build": {
"env": {
"APP_STAGE": "staging",
"NRN_PRESET": "v1-ssr-mst-aptd-gcms-lcz-sty",
"NRN_PRESET": "v1-hyb-mst-aptd-gcms-lcz-sty",
"CUSTOMER_REF": "customer2",
"GRAPHQL_API_ENDPOINT": "https://api-euwest.graphcms.com/v1/ck73ixhlv09yt01dv2ga1bkbp/master",
"GRAPHQL_API_KEY": "@nrn-graphql-api-key",
"LOCIZE_PROJECT_ID": "@nrn-locize-project-id",
"LOCIZE_API_KEY": "@nrn-locize-api-key",
"LOCIZE_API_KEY": "@nrn-locize-api-key-staging",
"AMPLITUDE_API_KEY": "@nrn-amplitude-api-key-staging",
"SENTRY_DSN": "@nrn-sentry-dsn"
}
Expand Down
22 changes: 14 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"start": "now dev --listen 8888",
"build": "yarn test:once && next build",
"next": "next start",
"svg": "npx svgr -d src/svg src/svg --ext tsx --template ./src/utils/svgTemplate.ts",
"svg": "npx svgr -d src/svg src/svg --ext tsx --template src/utils/svg/svgTemplate.ts",
"deploy": "yarn deploy:customer1",
"deploy:all": "yarn deploy:customer1 && yarn deploy:customer2",
"deploy:all:production": "yarn deploy:customer1:production && yarn deploy:customer2:production",
Expand Down Expand Up @@ -50,6 +50,7 @@
},
"dependencies": {
"@amplitude/react-amplitude": "1.0.0",
"@apollo/react-hooks": "3.1.5",
"@apollo/react-ssr": "3.1.4",
"@emotion/core": "10.0.28",
"@emotion/styled": "10.0.27",
Expand All @@ -59,6 +60,7 @@
"@fortawesome/react-fontawesome": "0.1.9",
"@sentry/browser": "5.15.4",
"@sentry/node": "5.15.4",
"@types/lodash.filter": "4.6.6",
"@unly/universal-language-detector": "2.0.3",
"@unly/utils": "1.0.3",
"@unly/utils-simple-logger": "1.4.0",
Expand All @@ -77,14 +79,13 @@
"graphql": "15.0.0",
"graphql-tag": "2.10.3",
"i18next": "19.3.4",
"i18next-locize-backend": "3.1.1",
"i18next-node-locize-backend": "3.1.0",
"isomorphic-unfetch": "3.0.0",
"i18next-locize-backend": "4.0.7",
"js-cookie": "2.2.1",
"json-stringify-safe": "5.0.1",
"locize-editor": "3.0.0",
"locize-node-lastused": "2.0.0",
"locize-lastused": "3.0.3",
"lodash.clonedeep": "4.5.0",
"lodash.filter": "4.6.0",
"lodash.find": "4.6.0",
"lodash.get": "4.4.2",
"lodash.includes": "4.3.0",
Expand All @@ -93,8 +94,11 @@
"lodash.isplainobject": "4.0.6",
"lodash.map": "4.6.0",
"lodash.remove": "4.7.0",
"lodash.size": "4.2.0",
"lodash.some": "4.6.0",
"lodash.startswith": "4.2.1",
"lodash.xorby": "4.7.0",
"next": "9.3.4",
"next": "9.4.0",
"next-cookies": "2.0.3",
"next-with-apollo": "5.0.0",
"prop-types": "15.7.2",
Expand Down Expand Up @@ -125,17 +129,19 @@
"@types/lodash.isplainobject": "4.0.6",
"@types/lodash.map": "4.6.13",
"@types/lodash.remove": "4.7.6",
"@types/lodash.size": "4.2.6",
"@types/lodash.some": "4.6.6",
"@types/lodash.startswith": "4.2.6",
"@types/lodash.xorby": "4.7.6",
"@types/react": "16.9.32",
"@types/webfontloader": "1.6.29",
"@types/webpack-env": "1.15.1",
"@typescript-eslint/eslint-plugin": "2.26.0",
"@typescript-eslint/parser": "2.26.0",
"@zeit/next-css": "1.0.1",
"@zeit/next-source-maps": "0.0.4-canary.1",
"concurrently": "5.1.0",
"cross-env": "7.0.2",
"cypress": "4.3.0",
"cypress": "4.5.0",
"del-cli": "3.0.0",
"eslint": "6.8.0",
"eslint-plugin-jest": "23.8.2",
Expand Down

Large diffs are not rendered by default.

Loading