Skip to content

Commit b0fbb36

Browse files
authored
Merge pull request #271 from wunderio/feature/updates-etc-again
Updates, various small improvements to configs etc
2 parents d317787 + b8ac17f commit b0fbb36

File tree

96 files changed

+5415
-5202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+5415
-5202
lines changed

.circleci/config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ commands:
145145
fi
146146
147147
echo "export NEXT_PUBLIC_DRUPAL_BASE_URL=https://$drupal_domain" >> "$BASH_ENV"
148-
echo "export NEXT_IMAGE_DOMAIN=$drupal_domain" >> "$BASH_ENV"
149148
echo "export NEXT_PUBLIC_FRONTEND_URL=https://$next_domain" >> "$BASH_ENV"
150149
echo "export AUTH_URL=https://$next_domain" >> "$BASH_ENV"
151150
echo "export DRUPAL_CLIENT_ID=$drupal_client_id" >> "$BASH_ENV"
@@ -160,7 +159,7 @@ commands:
160159
161160
echo "Expanding special variable DRUPAL_CLIENT_ID = $drupal_client_id ..."
162161
sed -i -e "s/<|DRUPAL_CLIENT_ID|>/$drupal_client_id/g" $envvars_file
163-
162+
164163
echo "Expanding special variable ES_HOST = $elasticsearch_host ..."
165164
sed -i -e "s/<|ES_HOST|>/$elasticsearch_host/g" $envvars_file
166165

.ddev/config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ web_environment:
3333
- ENVIRONMENT_NAME=ddev
3434
- HASH_SALT=notsosecurehashnotsosecurehashnotsosecurehash
3535
- NEXT_PUBLIC_DRUPAL_BASE_URL=https://next-drupal-starterkit.ddev.site
36-
- NEXT_IMAGE_DOMAIN=next-drupal-starterkit.ddev.site
3736
- NEXT_PUBLIC_FRONTEND_URL=https://next-drupal-starterkit.ddev.site:3000
3837
# Environment variables for next_auth:
3938
- AUTH_SECRET=nextauth_secret_not_secure_used_only_locally

.lando.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ services:
135135
globals:
136136
npm: latest
137137
overrides:
138-
image: "cypress/included:cypress-13.6.4-node-20.11.0-chrome-121.0.6167.85-1-ff-120.0-edge-121.0.2277.83-1"
138+
image: "cypress/included:cypress-13.15.1-node-20.18.0-chrome-130.0.6723.69-1-ff-131.0.3-edge-130.0.2849.52-1"
139139
ports:
140140
- "3000:3000"
141141
- "6006:6006"
@@ -152,10 +152,8 @@ services:
152152
DRUPAL_CLIENT_VIEWER_ID: drupal-client-viewer-id
153153
DRUPAL_CLIENT_VIEWER_SECRET: drupal_client_viewer_secret_not_secure_used_only_locally
154154
NEXT_PUBLIC_DRUPAL_BASE_URL: https://next-drupal-starterkit.lndo.site
155-
NEXT_IMAGE_DOMAIN: next-drupal-starterkit.lndo.site
156155
NEXT_PUBLIC_FRONTEND_URL: https://frontend.lndo.site
157156
# Environment variables for next_auth:
158-
# Environment variables for next_auth:
159157
AUTH_SECRET: nextauth_secret_not_secure_used_only_locally
160158
AUTH_TRUST_HOST: true
161159
AUTH_URL: https://frontend.lndo.site

next/.env.local.example

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##
2+
# This file contains env variables that are not generally required,
3+
# but can be useful for development and debugging.
4+
#
5+
# To use something in this file:
6+
# 1. Create a file .env.local with the same content as this one.
7+
# 2. Uncomment the variables you want to enable.
8+
##
9+
10+
# Disable telemetry:
11+
# NEXT_TELEMETRY_DISABLED=1
12+
13+
# Skip ESLint and TypeScript checks:
14+
# NEXT_BUILD_SKIP_CHECKS=1

next/.eslintrc.js

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ module.exports = {
3535
browser: true,
3636
node: true,
3737
},
38-
plugins: ["n", "simple-import-sort"],
38+
plugins: ["n", "simple-import-sort", "react", "@typescript-eslint"],
3939
extends: [
4040
"eslint:recommended",
41+
"plugin:react/recommended",
4142
"plugin:@typescript-eslint/recommended",
4243
"plugin:@typescript-eslint/recommended-requiring-type-checking",
4344
"next",
@@ -50,39 +51,25 @@ module.exports = {
5051
// Remove these if you want to enforce stricter rules.
5152
"@typescript-eslint/ban-ts-comment": "off",
5253
"@typescript-eslint/no-explicit-any": "off",
53-
"@typescript-eslint/no-non-null-assertion": "off",
5454
"@typescript-eslint/no-unsafe-argument": "off",
5555
"@typescript-eslint/no-unsafe-assignment": "off",
5656
"@typescript-eslint/no-unsafe-call": "off",
5757
"@typescript-eslint/no-unsafe-member-access": "off",
5858
"@typescript-eslint/no-unsafe-return": "off",
5959
"@typescript-eslint/restrict-template-expressions": "off",
60-
"@typescript-eslint/no-empty-object-type": "off",
61-
"@typescript-eslint/no-require-imports": "off",
62-
"@typescript-eslint/no-unused-expressions": "off",
63-
"@typescript-eslint/no-unused-vars": "off",
64-
"@typescript-eslint/no-misused-promises": [
65-
"error",
66-
{
67-
checksVoidReturn: {
68-
attributes: false,
69-
},
70-
},
71-
],
7260

7361
// Instead, `import { env } from "@/env"` to access environment variables.
7462
"n/no-process-env": ["error"],
7563

76-
"no-restricted-imports": [
64+
// Allow unused variables only if they start with `_` or `err`.
65+
"no-unused-vars": "off",
66+
"@typescript-eslint/no-unused-vars": [
7767
"error",
7868
{
79-
paths: [
80-
// Restrict i18n imports to ensure SSR compatibility.
81-
{
82-
name: "react-i18next",
83-
message: 'Import from "next-i18next" instead.',
84-
},
85-
],
69+
vars: "all",
70+
varsIgnorePattern: "^_",
71+
args: "after-used",
72+
argsIgnorePattern: "^_|^err",
8673
},
8774
],
8875

@@ -96,9 +83,7 @@ module.exports = {
9683
// Packages. Put `next`/`react`-related packages first.
9784
["^next", "^@next", "^react", "^@?\\w"],
9885
// Internal paths - change these to match your project structure defined in tsconfig.json.
99-
["^@/(components|lib|pages|styles|types)(/.*|$)"],
100-
// UI library imports.
101-
["^@ui(/.*|$)"],
86+
["^@/(app|components|lib|pages|styles|types)(/.*|$)"],
10287
// Parent imports. Put `..` last.
10388
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
10489
// Other relative imports. Put same-folder imports and `.` last.

next/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ lerna-debug.log*
4343
# files generated by graphql-codegen
4444
/src/lib/gql
4545
/src/lib/graphql/schema.graphql
46+
47+
# allow .env.local.example:
48+
!.env.local.example

next/.prettierrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
{}
1+
{
2+
"plugins": [
3+
"prettier-plugin-tailwindcss"
4+
]
5+
}

next/codegen-access-token.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1+
/* eslint-disable n/no-process-env */
2+
/* eslint-disable @typescript-eslint/no-require-imports */
3+
14
/**
25
* Gets an access token from Drupal and saves it the temporary directory,
36
* so it can be used by graphql-codegen to authenticate to the Drupal GraphQL API.
47
*/
58
void (async function getAndSaveAccessToken() {
69
try {
7-
/* eslint-disable @typescript-eslint/no-var-requires */
810
const { loadEnvConfig } = require("@next/env");
911
const fs = require("fs");
1012
const path = require("path");
1113
const os = require("os");
12-
/* eslint-enable @typescript-eslint/no-var-requires */
1314

1415
loadEnvConfig(process.cwd());
1516

16-
/* eslint-disable n/no-process-env */
1717
const oauthUrl = `${process.env.NEXT_PUBLIC_DRUPAL_BASE_URL}/oauth/token`;
1818
const credentials = Buffer.from(
1919
`${process.env.DRUPAL_CLIENT_ID}:${process.env.DRUPAL_CLIENT_SECRET}`,
2020
).toString("base64");
21-
/* eslint-enable n/no-process-env */
2221

2322
const response = await fetch(oauthUrl, {
2423
method: "POST",

next/codegen.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable n/no-process-env */
2+
13
import { loadEnvConfig } from "@next/env";
24
import type { CodegenConfig } from "@graphql-codegen/cli";
35
import fs from "fs";
@@ -9,7 +11,6 @@ const token = fs.readFileSync(tokenFilePath, "utf8").trim();
911

1012
loadEnvConfig(process.cwd());
1113

12-
/* eslint-disable-next-line n/no-process-env */
1314
const schemaUrl = `${process.env.NEXT_PUBLIC_DRUPAL_BASE_URL}/graphql`;
1415

1516
const config: CodegenConfig = {
Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,58 @@
1-
const crypto = require("crypto");
1+
// @ts-check
2+
3+
import { randomUUID } from "node:crypto";
4+
import createNextIntlPlugin from "next-intl/plugin";
25

3-
const createNextIntlPlugin = require("next-intl/plugin");
46
const withNextIntl = createNextIntlPlugin();
57

8+
const imageHostname = String(process.env.NEXT_PUBLIC_DRUPAL_BASE_URL).split(
9+
"://",
10+
)[1];
11+
612
/** @type {import('next').NextConfig} */
713
const nextConfig = {
814
reactStrictMode: true,
9-
// Only generate standalone output in circle ci:
15+
poweredByHeader: false,
1016
output: process.env.CIRCLECI ? "standalone" : undefined,
11-
generateBuildId: async () => {
12-
// This environment variable is set by CircleCI.
13-
// adjust this to your needs if you use another CI/CD tool.
14-
return process.env.CIRCLE_BUILD_NUM
15-
? `build-id-${process.env.CIRCLE_BUILD_NUM}`
16-
: // If no build number is available, we generate a random build ID.
17-
crypto.randomBytes(20).toString("hex");
18-
},
17+
1918
cacheHandler:
2019
// Only use the cache handler in production
2120
process.env.NODE_ENV === "production"
22-
? require.resolve("./cache-handler.mjs")
21+
? new URL("./cache-handler.mjs", import.meta.url).pathname
2322
: undefined,
2423
cacheMaxMemorySize: 0, // Disable in-memory cache
25-
experimental: {
26-
// This is required for the experimental feature of pre-populating the cache with the initial data
27-
instrumentationHook: true,
28-
},
29-
poweredByHeader: false,
24+
3025
images: {
3126
remotePatterns: [
3227
{
3328
protocol: "https",
34-
hostname: process.env.NEXT_IMAGE_DOMAIN,
29+
hostname: imageHostname,
3530
pathname: "**",
3631
},
3732
],
3833
},
34+
35+
experimental: {
36+
instrumentationHook: true,
37+
swrDelta: 31536000, // 1 year
38+
},
39+
40+
async generateBuildId() {
41+
return process.env.CIRCLECI
42+
? String(process.env.CIRCLE_BUILD_NUM)
43+
: randomUUID().split("-")[0];
44+
},
45+
46+
async rewrites() {
47+
return [
48+
// Expose health check endpoint at /_ping:
49+
{
50+
source: "/_ping",
51+
destination: "/api/health",
52+
},
53+
];
54+
},
55+
3956
webpack(config) {
4057
// Grab the existing rule that handles SVG imports
4158
const fileLoaderRule = config.module.rules.find((rule) =>
@@ -57,9 +74,13 @@ const nextConfig = {
5774

5875
return config;
5976
},
60-
experimental: {
61-
swrDelta: 31536000, // 1 year
77+
78+
eslint: {
79+
ignoreDuringBuilds: Boolean(process.env.NEXT_BUILD_SKIP_CHECKS),
80+
},
81+
typescript: {
82+
ignoreBuildErrors: Boolean(process.env.NEXT_BUILD_SKIP_CHECKS),
6283
},
6384
};
6485

65-
module.exports = withNextIntl(nextConfig);
86+
export default withNextIntl(nextConfig);

0 commit comments

Comments
 (0)