Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: expatfile/next-runtime-env
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.6.0-alpha.2
Choose a base ref
...
head repository: expatfile/next-runtime-env
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: development
Choose a head ref
Loading
Showing with 13,997 additions and 9,479 deletions.
  1. +3 −2 .eslintrc.js
  2. +9 −4 .github/actions/back-merge/action.yml
  3. +8 −31 .github/actions/setup-pnpm/action.yml
  4. +0 −24 .github/dependabot.yml
  5. +12 −7 .github/workflows/ci.yml
  6. +2 −2 .github/workflows/release.yml
  7. +6 −0 .releaserc.yaml
  8. +52 −173 README.md
  9. +86 −0 docs/EXPOSING_CUSTOM_ENV.md
  10. +115 −0 docs/GETTING_STARTED.md
  11. +20 −0 docs/MAKING_ENV_PUBLIC.md
  12. 0 examples/{with-app-router → with-app-router-context}/.eslintrc.json
  13. 0 examples/{with-app-router → with-app-router-context}/.gitignore
  14. 0 examples/{with-app-router → with-app-router-context}/.vscode/settings.json
  15. +6 −6 examples/{with-app-router → with-app-router-context}/README.md
  16. +11 −0 examples/with-app-router-context/next.config.js
  17. +9 −9 examples/{with-app-router → with-app-router-context}/package.json
  18. +3,015 −0 examples/with-app-router-context/pnpm-lock.yaml
  19. 0 examples/{with-app-router → with-app-router-context}/public/next.svg
  20. 0 examples/{with-app-router → with-app-router-context}/public/vercel.svg
  21. +12 −0 examples/with-app-router-context/src/app/api/bar-baz/route.ts
  22. 0 examples/{with-app-router → with-app-router-context}/src/app/client-side/page.module.css
  23. +21 −0 examples/with-app-router-context/src/app/client-side/page.tsx
  24. BIN examples/{with-app-router → with-app-router-context}/src/app/favicon.ico
  25. 0 examples/{with-app-router → with-app-router-context}/src/app/globals.css
  26. +25 −0 examples/with-app-router-context/src/app/layout.tsx
  27. 0 examples/{with-app-router → with-app-router-context}/src/app/page.module.css
  28. 0 examples/{with-app-router → with-app-router-context}/src/app/page.tsx
  29. 0 examples/{with-app-router → with-app-router-context}/src/app/server-side/page.module.css
  30. +21 −0 examples/with-app-router-context/src/app/server-side/page.tsx
  31. +7 −0 examples/with-app-router-context/src/instrumentation.ts
  32. 0 examples/{with-app-router → with-app-router-context}/tsconfig.json
  33. 0 examples/{with-pages-router → with-app-router-script}/.eslintrc.json
  34. 0 examples/{with-pages-router → with-app-router-script}/.gitignore
  35. +1 −0 examples/with-app-router-script/.vscode/settings.json
  36. +39 −0 examples/with-app-router-script/README.md
  37. +10 −0 examples/with-app-router-script/next.config.js
  38. +23 −0 examples/with-app-router-script/package.json
  39. +3,015 −0 examples/with-app-router-script/pnpm-lock.yaml
  40. 0 examples/{with-pages-router → with-app-router-script}/public/next.svg
  41. 0 examples/{with-pages-router → with-app-router-script}/public/vercel.svg
  42. +8 −0 examples/with-app-router-script/src/app/api/bar-baz/route.ts
  43. 0 ...s-router/src/styles/Home.module.css → with-app-router-script/src/app/client-side/page.module.css}
  44. +5 −1 examples/{with-app-router → with-app-router-script}/src/app/client-side/page.tsx
  45. BIN examples/{with-pages-router/public → with-app-router-script/src/app}/favicon.ico
  46. 0 examples/{with-pages-router/src/styles → with-app-router-script/src/app}/globals.css
  47. +2 −2 examples/{with-app-router → with-app-router-script}/src/app/layout.tsx
  48. +229 −0 examples/with-app-router-script/src/app/page.module.css
  49. +96 −0 examples/with-app-router-script/src/app/page.tsx
  50. +229 −0 examples/with-app-router-script/src/app/server-side/page.module.css
  51. +5 −1 examples/{with-app-router → with-app-router-script}/src/app/server-side/page.tsx
  52. +7 −0 examples/with-app-router-script/src/instrumentation.ts
  53. +61 −0 examples/with-app-router-script/src/middleware.ts
  54. +6 −1 examples/{with-pages-router → with-app-router-script}/tsconfig.json
  55. +0 −8 examples/with-app-router/next.config.js
  56. +0 −2,341 examples/with-app-router/pnpm-lock.yaml
  57. +0 −1 examples/with-pages-router/.vscode/settings.json
  58. +1 −39 examples/with-pages-router/README.md
  59. +0 −10 examples/with-pages-router/next.config.js
  60. +0 −23 examples/with-pages-router/package.json
  61. +0 −2,347 examples/with-pages-router/pnpm-lock.yaml
  62. +0 −7 examples/with-pages-router/src/pages/_app.tsx
  63. +0 −16 examples/with-pages-router/src/pages/_document.tsx
  64. +0 −13 examples/with-pages-router/src/pages/api/hello.ts
  65. +0 −25 examples/with-pages-router/src/pages/client-side.tsx
  66. +0 −115 examples/with-pages-router/src/pages/index.tsx
  67. +0 −38 examples/with-pages-router/src/pages/server-side.tsx
  68. +2 −1 jest.config.js
  69. +26 −16 package.json
  70. +5,763 −3,793 pnpm-lock.yaml
  71. +0 −1 prettier.config.js
  72. +33 −0 scripts/upgrade_deps.sh
  73. +0 −52 src/all-env.spec.ts
  74. +0 −14 src/all-env.ts
  75. +0 −57 src/configure.spec.ts
  76. +0 −29 src/configure.ts
  77. +0 −14 src/env.ts
  78. +0 −22 src/helpers/get-public-env.spec.ts
  79. +2 −6 src/helpers/get-public-env.ts
  80. +3 −1 src/{utils → helpers}/is-browser.ts
  81. +79 −0 src/helpers/log.spec.ts
  82. +73 −0 src/helpers/log.ts
  83. +0 −88 src/helpers/write-browser-env.spec.ts
  84. +0 −25 src/helpers/write-browser-env.ts
  85. +3 −2 src/index.ts
  86. +86 −0 src/lib/picocolors.ts
  87. +0 −44 src/make-env-public.ts
  88. +5 −0 src/provider/env-context.ts
  89. +48 −0 src/provider/env-provider.spec.tsx
  90. +24 −0 src/provider/env-provider.tsx
  91. +5 −0 src/provider/index.ts
  92. +101 −0 src/provider/public-env-provider.spec.tsx
  93. +30 −0 src/provider/public-env-provider.tsx
  94. +71 −0 src/provider/use-env-context.spec.tsx
  95. +25 −0 src/provider/use-env-context.ts
  96. +1 −0 src/script/constants.ts
  97. +91 −0 src/script/env-script.spec.tsx
  98. +65 −0 src/script/env-script.tsx
  99. +16 −1 src/{ → script}/env.spec.ts
  100. +29 −0 src/script/env.ts
  101. +6 −0 src/script/index.ts
  102. +80 −0 src/script/public-env-script.spec.tsx
  103. +47 −0 src/script/public-env-script.tsx
  104. +3 −0 src/typings/dict.ts
  105. +3 −0 src/typings/nonce.ts
  106. +3 −0 src/typings/process-env.ts
  107. +0 −30 src/utils/log.ts
  108. +34 −33 src/{ → utils}/make-env-public.spec.ts
  109. +57 −0 src/utils/make-env-public.ts
  110. +6 −4 tsconfig.json
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ module.exports = {
'eol-last': ['error', 'always'],
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'import/extensions': ['off'],
'import/order': ['off'],
'import/prefer-default-export': ['off'],
'simple-import-sort/imports': 'warn',
'simple-import-sort/exports': 'warn',
@@ -27,7 +28,7 @@ module.exports = {
},
overrides: [
{
files: ['src/__mocks__/.*', '**/*.spec.ts'],
files: ['src/__mocks__/.*', '**/*.spec.ts', '**/*.spec.tsx'],
rules: {
'import/no-extraneous-dependencies': [
'error',
@@ -41,7 +42,7 @@ module.exports = {
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.ts'],
extensions: ['.js', '.ts', '.jsx', '.tsx'],
},
},
},
13 changes: 9 additions & 4 deletions .github/actions/back-merge/action.yml
Original file line number Diff line number Diff line change
@@ -22,21 +22,26 @@ runs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ inputs.gh_token }}

- name: Setup git config
shell: bash
env:
GIT_USER_EMAIL: ${{ inputs.git_user_email }}
GIT_USER_NAME: ${{ inputs.git_user_name }}
run: |
git config --global user.email ${{ inputs.git_user_email }}
git config --global user.name ${{ inputs.git_user_name }}
git config --global user.email "${GIT_USER_EMAIL}"
git config --global user.name "${GIT_USER_NAME}"
- name: Merge main back to development
shell: bash
env:
MAIN_BRANCH: ${{ inputs.main_branch }}
run: |
git fetch --unshallow
git checkout development
git pull
git merge --no-ff origin/${{ inputs.main_branch }} -m "Back-merge ${{ inputs.main_branch }} into development"
git merge --no-ff "origin/${MAIN_BRANCH}" -m "ci: 🔀 back-merge ${MAIN_BRANCH} into development"
git push
39 changes: 8 additions & 31 deletions .github/actions/setup-pnpm/action.yml
Original file line number Diff line number Diff line change
@@ -15,44 +15,21 @@ runs:
using: "composite"

steps:
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
id: pnpm-install
with:
version: 8
version: 9
run_install: false

- name: Set pnpm home
shell: bash
run: |
echo "PNPM_HOME=$HOME/.local/share/pnpm" >> $GITHUB_ENV
echo "$HOME/.local/share/pnpm" >> $GITHUB_PATH
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Authenticate for private NPM package
shell: bash
node-version: ${{ matrix.node-version }}
cache: pnpm
registry-url: 'https://registry.npmjs.org'
env:
NPM_TOKEN: ${{ inputs.npm_token }}
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
NODE_AUTH_TOKEN: ${{ inputs.npm_token }}

- name: Install dependencies
shell: bash
24 changes: 0 additions & 24 deletions .github/dependabot.yml

This file was deleted.

19 changes: 12 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Continuous Integration

on:
pull_request:
branches:
- development
push:
# branches-ignore:
# - main
@@ -17,11 +20,11 @@ jobs:

strategy:
matrix:
node-version: [16, 18]
node-version: [18, 20, 22]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup pnpm
uses: ./.github/actions/setup-pnpm
@@ -39,11 +42,11 @@ jobs:

strategy:
matrix:
node-version: [16, 18]
node-version: [18, 20, 22]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup pnpm
uses: ./.github/actions/setup-pnpm
@@ -61,11 +64,11 @@ jobs:

strategy:
matrix:
node-version: [16, 18]
node-version: [18, 20, 22]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup pnpm
uses: ./.github/actions/setup-pnpm
@@ -78,8 +81,10 @@ jobs:
--ci \
--runInBand \
--coverage
env:
JEST_JUNIT_CLASSNAME: '{filepath}'

- name: Upload code coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -17,11 +17,11 @@ jobs:

strategy:
matrix:
node-version: [18]
node-version: [22]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup pnpm
uses: ./.github/actions/setup-pnpm
6 changes: 6 additions & 0 deletions .releaserc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
branches:
- name: 1.x
range: 1.x
channel: 1.x
- name: 2.x
range: 2.x
channel: 2.x
- main
- name: development
prerelease: alpha
Loading