From 1efc5dd1d3bbcf96e00288782dfba1c05e7e1601 Mon Sep 17 00:00:00 2001 From: joneshector <89353359+joneshector@users.noreply.github.com> Date: Fri, 19 Jul 2024 07:40:26 +0100 Subject: [PATCH] Merges pre-push git hooks from develop into main (#96) * [GIT SETUP] Tests pre push hook, disallowing direct push to develop Problem Solution Note * [GIT SETUP] Adds pre commit script Problem Solution Note * [GIT SETUP] Finalises pre commit hook script Problem Solution Note * [GIT SETUP] Changes git hook to pre push instead of pre commit Problem Solution Note * [GIT SETUP] Updates pre-push script comments Problem Solution Note * [GIT SETUP] Updates readme with git hook setup instructions Problem Solution Note * HOTFIX - Add Google Analytics (#97) Co-authored-by: marcaufderheyde --------- Co-authored-by: Marc Auf der Heyde Co-authored-by: marcaufderheyde --- README.md | 17 ++++++++++++----- app/layout.tsx | 25 ++++++++++++++++++++++++- app/ui/Navigation/hamburgerbutton.tsx | 1 + app/ui/Navigation/links.tsx | 6 ++++-- app/ui/Navigation/navbar.tsx | 1 + package.json | 3 ++- scripts/pre-push | 23 +++++++++++++++++++++++ 7 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 scripts/pre-push diff --git a/README.md b/README.md index 9e0cbd8..fb143a6 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,31 @@ # The CCB Project + Main repository for cannabisclubsberlin.com, berlincannabisclubs.de and berlincannabisclubs.info ## The CCB Project -This is the project of Marc, Hector and Fabrizio. This is a webapp to discover new clubs in Berlin. + +This is the project of Marc, Hector and Fabrizio. This is a webapp to discover new clubs in Berlin. ## Environment Requirements: -- NodeJS v20 (LTS): (https://nodejs.org/en) -- NPM -- NextJS +- NodeJS v20 (LTS): (https://nodejs.org/en) +- NPM +- NextJS ## Getting Started - First, install dependencies: ```bash npm install ``` +Next, run the setup scripts: + +```bash +npm run prestart +``` + Next, run the development server: ```bash diff --git a/app/layout.tsx b/app/layout.tsx index d2503af..004fc1a 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -3,6 +3,7 @@ import { Inter } from 'next/font/google'; import 'leaflet/dist/leaflet.css'; import 'leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.webpack.css'; import './globals.css'; +import Script from 'next/script'; const inter = Inter({ subsets: ['latin'] }); @@ -23,7 +24,29 @@ export default function RootLayout({ }>) { return ( - {children} + + + + + {/* Google Tag Manager (noscript) */} + + {children} + ); } diff --git a/app/ui/Navigation/hamburgerbutton.tsx b/app/ui/Navigation/hamburgerbutton.tsx index 1ed4c07..6da54b4 100644 --- a/app/ui/Navigation/hamburgerbutton.tsx +++ b/app/ui/Navigation/hamburgerbutton.tsx @@ -18,6 +18,7 @@ export default function HamburgerButton({ > }) { 'text-[#E3E71F] font-bold text-xl group transition duration-300'; const defaultLinkStyling = 'font-normal text-xl group transition duration-300'; + // @ts-ignore const isHomePage = isPathNameHome(pathname); return ( -
+
{links.map((link: LinkInfo) => { return ( }) { } > {link.name as String} - + ); })} diff --git a/app/ui/Navigation/navbar.tsx b/app/ui/Navigation/navbar.tsx index bb3fce1..2ef1ba5 100644 --- a/app/ui/Navigation/navbar.tsx +++ b/app/ui/Navigation/navbar.tsx @@ -33,6 +33,7 @@ export default function Navbar({ isOnMap = false }: Props) { ]; const pathname = usePathname(); + // @ts-ignore const fontColor = isPathNameHome(pathname) ? 'text-white' : 'text-[#868686]'; diff --git a/package.json b/package.json index af10008..5e85a7c 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "build": "next build", "postbuild": "node ./generate-sitemap.mjs", "start": "next start", - "lint": "next lint" + "lint": "next lint", + "prestart": "cp scripts/pre-push .git/hooks/ && chmod +x .git/hooks/pre-push && echo 'hook copied'" }, "dependencies": { "globby": "^14.0.1", diff --git a/scripts/pre-push b/scripts/pre-push new file mode 100644 index 0000000..1125355 --- /dev/null +++ b/scripts/pre-push @@ -0,0 +1,23 @@ +#!/bin/sh + +echo "*****Running pre push build******" + +cmd="npm run build" + +#!/bin/bash + +current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') + +if [ 'develop' = ${current_branch} ] +then + echo "ERROR: Cannot push to develop. Switch to a different branch and create a pull request." + exit 1 # push will not execute +else + eval $cmd + result=$? + if ! eval "$cmd"; then + echo "failed $cmd" >&2 + exit 1 + fi +fi +exit 0 # push will execute \ No newline at end of file