From a317667b2e0895ddedd470e284d84d0c63b9f824 Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Tue, 18 Mar 2025 18:23:18 -0400 Subject: [PATCH 01/19] Add script file --- scripts/custom-publish.sh | 84 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 scripts/custom-publish.sh diff --git a/scripts/custom-publish.sh b/scripts/custom-publish.sh new file mode 100644 index 000000000..862fc1e99 --- /dev/null +++ b/scripts/custom-publish.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# Exit immediately on error, and treat unset variables as errors. +set -euo pipefail + +# Color definitions. +GREEN="\033[0;32m" +YELLOW="\033[0;33m" +BLUE="\033[0;34m" +RED="\033[0;31m" +NC="\033[0m" # No Color + +# Check that we are in a Git repository. +if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + echo -e "${RED}[ERROR]${NC} Not inside a Git repository. Exiting." + exit 1 +fi + +# Ensure a clean working directory. +if [ -n "$(git status --porcelain)" ]; then + echo -e "${RED}[ERROR]${NC} Working directory is not clean. Please commit or stash your changes." + exit 1 +fi + +# Save the current branch name. +CURRENT_BRANCH=$(git symbolic-ref --short HEAD) +echo -e "${BLUE}[INFO]${NC} Current branch: ${GREEN}${CURRENT_BRANCH}${NC}" + +# Create a temporary directory for the build output. +TMP_DIR=$(mktemp -d -t custom-build-XXXXXXXX) +echo -e "${BLUE}[INFO]${NC} Using temporary directory: ${GREEN}$TMP_DIR${NC}" + +# Ensure the temporary directory is removed on exit. +function cleanup { + echo -e "${YELLOW}[CLEANUP]${NC} Removing temporary directory..." + rm -rf "$TMP_DIR" +} +trap cleanup EXIT + +# Run the build. +echo -e "${BLUE}[BUILD]${NC} Running build..." +yarn build + +# Verify the build output exists. +if [ ! -d "packages/formik" ]; then + echo -e "${RED}[ERROR]${NC} Build output directory 'packages/formik' does not exist. Exiting." + exit 1 +fi + +# Copy the built package to the temporary directory. +echo -e "${BLUE}[BUILD]${NC} Copying built package to temporary directory..." +cp -R packages/formik/. "$TMP_DIR/" + +# Check if the custom-build branch exists. If yes, checkout; if not, create it. +if git rev-parse --verify custom-build >/dev/null 2>&1; then + echo -e "${BLUE}[BRANCH]${NC} Branch 'custom-build' exists. Checking it out..." + git checkout custom-build +else + echo -e "${BLUE}[BRANCH]${NC} Branch 'custom-build' does not exist. Creating orphan branch..." + git checkout --orphan custom-build +fi + +# Remove all files from the branch. +echo -e "${BLUE}[BRANCH]${NC} Clearing files from 'custom-build' branch..." +git rm -rf . > /dev/null 2>&1 || true + +# Copy the built files into the branch root. +echo -e "${BLUE}[DEPLOY]${NC} Copying built files to branch root..." +cp -R "$TMP_DIR/." . + +# Stage and commit the changes. +echo -e "${BLUE}[DEPLOY]${NC} Staging files..." +git add . +echo -e "${BLUE}[DEPLOY]${NC} Committing build..." +git commit -m "Auto commit -- publish custom build" + +# Force-push the branch to origin. +echo -e "${BLUE}[DEPLOY]${NC} Pushing 'custom-build' branch to origin..." +git push -f origin custom-build + +# Switch back to the original branch. +echo -e "${BLUE}[BRANCH]${NC} Switching back to original branch: ${GREEN}${CURRENT_BRANCH}${NC}..." +git checkout "$CURRENT_BRANCH" + +echo -e "${GREEN}[SUCCESS]${NC} Custom publish completed successfully!" From cd61c0b44057523d35cf08c29cdd76c5bc08b40b Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Tue, 18 Mar 2025 18:23:54 -0400 Subject: [PATCH 02/19] Add custom publish command --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 8a8257ebd..3d0d7949f 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "precommit": "lint-staged", "e2e:ui": "playwright test --ui", "start:app": "turbo run build --filter formik... && yarn --cwd packages/formik link && yarn --cwd ./app link formik && yarn --cwd ./app && yarn --cwd ./app run dev", - "benchmark": "tsx scripts/benchmark.tsx | tee output.txt" + "benchmark": "tsx scripts/benchmark.tsx | tee output.txt", + "custom-publish": "bash ./scripts/custom-publish.sh" }, "lint-staged": { "**/*.{ts,tsx,md,mdx,js,jsx}": [ From 5005433f475bc2f38fffaafdddca465f177ce99f Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Tue, 18 Mar 2025 18:34:48 -0400 Subject: [PATCH 03/19] Update readme --- packages/formik/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/formik/README.md b/packages/formik/README.md index 8105b49d0..f8595d10f 100644 --- a/packages/formik/README.md +++ b/packages/formik/README.md @@ -1,3 +1,20 @@ +# Formik Fork + +This Fork has a `custom-publish` script. + +```bash +yarn custom-publish +``` + +This script builds the package and updates a dedicated `custom-build` branch containing only the distributable files. It then commits and force‑pushes these changes to GitHub, allowing you to continuously install the latest build with: + +```bash +yarn add git+https://github.com/zduvall/formik.git#custom-build +``` +--- + +# Formik Original Readme: +

Formik.js

From 1070e08bb37aca3b2edd6884f6708fdb59f23145 Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Tue, 18 Mar 2025 18:43:08 -0400 Subject: [PATCH 04/19] Update git add command --- scripts/custom-publish.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/custom-publish.sh b/scripts/custom-publish.sh index 862fc1e99..a6982b0bf 100644 --- a/scripts/custom-publish.sh +++ b/scripts/custom-publish.sh @@ -69,7 +69,8 @@ cp -R "$TMP_DIR/." . # Stage and commit the changes. echo -e "${BLUE}[DEPLOY]${NC} Staging files..." -git add . +# Use 'git add -f' to force-add files that are ignored by `.gitignore` -- particularly the `dist` directory. +git add -f . echo -e "${BLUE}[DEPLOY]${NC} Committing build..." git commit -m "Auto commit -- publish custom build" From d9109561496a2d9a33a6ab0fb4df75e71e77f5d5 Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Tue, 18 Mar 2025 18:58:12 -0400 Subject: [PATCH 05/19] Move branch switching functionality --- scripts/custom-publish.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/custom-publish.sh b/scripts/custom-publish.sh index a6982b0bf..f3d1169d0 100644 --- a/scripts/custom-publish.sh +++ b/scripts/custom-publish.sh @@ -31,6 +31,9 @@ echo -e "${BLUE}[INFO]${NC} Using temporary directory: ${GREEN}$TMP_DIR${NC}" # Ensure the temporary directory is removed on exit. function cleanup { + echo -e "${YELLOW}[CLEANUP]${NC} Switching back to original branch: ${GREEN}${CURRENT_BRANCH}${NC}..." + git checkout "$CURRENT_BRANCH" || echo -e "${RED}[ERROR]${NC} Failed to switch back to original branch." + echo -e "${YELLOW}[CLEANUP]${NC} Removing temporary directory..." rm -rf "$TMP_DIR" } @@ -78,8 +81,4 @@ git commit -m "Auto commit -- publish custom build" echo -e "${BLUE}[DEPLOY]${NC} Pushing 'custom-build' branch to origin..." git push -f origin custom-build -# Switch back to the original branch. -echo -e "${BLUE}[BRANCH]${NC} Switching back to original branch: ${GREEN}${CURRENT_BRANCH}${NC}..." -git checkout "$CURRENT_BRANCH" - echo -e "${GREEN}[SUCCESS]${NC} Custom publish completed successfully!" From d7220e05040b3ea39fddbf7ba97d09f1e58a57cb Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Tue, 18 Mar 2025 19:02:17 -0400 Subject: [PATCH 06/19] Add and use custom echo --- scripts/custom-publish.sh | 41 ++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/scripts/custom-publish.sh b/scripts/custom-publish.sh index f3d1169d0..44fcc4f48 100644 --- a/scripts/custom-publish.sh +++ b/scripts/custom-publish.sh @@ -9,76 +9,81 @@ BLUE="\033[0;34m" RED="\033[0;31m" NC="\033[0m" # No Color +# Custom echo function to add newlines before and after the string. +custom_echo() { + echo -e "\n$1\n" +} + # Check that we are in a Git repository. if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then - echo -e "${RED}[ERROR]${NC} Not inside a Git repository. Exiting." + custom_echo "${RED}[ERROR]${NC} Not inside a Git repository. Exiting." exit 1 fi # Ensure a clean working directory. if [ -n "$(git status --porcelain)" ]; then - echo -e "${RED}[ERROR]${NC} Working directory is not clean. Please commit or stash your changes." + custom_echo "${RED}[ERROR]${NC} Working directory is not clean. Please commit or stash your changes." exit 1 fi # Save the current branch name. CURRENT_BRANCH=$(git symbolic-ref --short HEAD) -echo -e "${BLUE}[INFO]${NC} Current branch: ${GREEN}${CURRENT_BRANCH}${NC}" +custom_echo "${BLUE}[INFO]${NC} Current branch: ${GREEN}${CURRENT_BRANCH}${NC}" # Create a temporary directory for the build output. TMP_DIR=$(mktemp -d -t custom-build-XXXXXXXX) -echo -e "${BLUE}[INFO]${NC} Using temporary directory: ${GREEN}$TMP_DIR${NC}" +custom_echo "${BLUE}[INFO]${NC} Using temporary directory: ${GREEN}$TMP_DIR${NC}" # Ensure the temporary directory is removed on exit. function cleanup { - echo -e "${YELLOW}[CLEANUP]${NC} Switching back to original branch: ${GREEN}${CURRENT_BRANCH}${NC}..." - git checkout "$CURRENT_BRANCH" || echo -e "${RED}[ERROR]${NC} Failed to switch back to original branch." + custom_echo "${YELLOW}[CLEANUP]${NC} Switching back to original branch: ${GREEN}${CURRENT_BRANCH}${NC}..." + git checkout "$CURRENT_BRANCH" || custom_echo "${RED}[ERROR]${NC} Failed to switch back to original branch." - echo -e "${YELLOW}[CLEANUP]${NC} Removing temporary directory..." + custom_echo "${YELLOW}[CLEANUP]${NC} Removing temporary directory..." rm -rf "$TMP_DIR" } trap cleanup EXIT # Run the build. -echo -e "${BLUE}[BUILD]${NC} Running build..." +custom_echo "${BLUE}[BUILD]${NC} Running build..." yarn build # Verify the build output exists. if [ ! -d "packages/formik" ]; then - echo -e "${RED}[ERROR]${NC} Build output directory 'packages/formik' does not exist. Exiting." + custom_echo "${RED}[ERROR]${NC} Build output directory 'packages/formik' does not exist. Exiting." exit 1 fi # Copy the built package to the temporary directory. -echo -e "${BLUE}[BUILD]${NC} Copying built package to temporary directory..." +custom_echo "${BLUE}[BUILD]${NC} Copying built package to temporary directory..." cp -R packages/formik/. "$TMP_DIR/" # Check if the custom-build branch exists. If yes, checkout; if not, create it. if git rev-parse --verify custom-build >/dev/null 2>&1; then - echo -e "${BLUE}[BRANCH]${NC} Branch 'custom-build' exists. Checking it out..." + custom_echo "${BLUE}[BRANCH]${NC} Branch 'custom-build' exists. Checking it out..." git checkout custom-build else - echo -e "${BLUE}[BRANCH]${NC} Branch 'custom-build' does not exist. Creating orphan branch..." + custom_echo "${BLUE}[BRANCH]${NC} Branch 'custom-build' does not exist. Creating orphan branch..." git checkout --orphan custom-build fi # Remove all files from the branch. -echo -e "${BLUE}[BRANCH]${NC} Clearing files from 'custom-build' branch..." +custom_echo "${BLUE}[BRANCH]${NC} Clearing files from 'custom-build' branch..." git rm -rf . > /dev/null 2>&1 || true # Copy the built files into the branch root. -echo -e "${BLUE}[DEPLOY]${NC} Copying built files to branch root..." +custom_echo "${BLUE}[DEPLOY]${NC} Copying built files to branch root..." cp -R "$TMP_DIR/." . # Stage and commit the changes. -echo -e "${BLUE}[DEPLOY]${NC} Staging files..." +custom_echo "${BLUE}[DEPLOY]${NC} Staging files..." # Use 'git add -f' to force-add files that are ignored by `.gitignore` -- particularly the `dist` directory. git add -f . -echo -e "${BLUE}[DEPLOY]${NC} Committing build..." +custom_echo "${BLUE}[DEPLOY]${NC} Committing build..." git commit -m "Auto commit -- publish custom build" # Force-push the branch to origin. -echo -e "${BLUE}[DEPLOY]${NC} Pushing 'custom-build' branch to origin..." +custom_echo "${BLUE}[DEPLOY]${NC} Pushing 'custom-build' branch to origin..." git push -f origin custom-build -echo -e "${GREEN}[SUCCESS]${NC} Custom publish completed successfully!" +custom_echo "${GREEN}[SUCCESS]${NC} Custom publish completed successfully!" From 0f0d5f99e8d23d22f896c4bed06660dda9d677c5 Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Tue, 18 Mar 2025 19:06:50 -0400 Subject: [PATCH 07/19] Update comment --- scripts/custom-publish.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/custom-publish.sh b/scripts/custom-publish.sh index 44fcc4f48..8dd2f58a7 100644 --- a/scripts/custom-publish.sh +++ b/scripts/custom-publish.sh @@ -34,7 +34,7 @@ custom_echo "${BLUE}[INFO]${NC} Current branch: ${GREEN}${CURRENT_BRANCH}${NC}" TMP_DIR=$(mktemp -d -t custom-build-XXXXXXXX) custom_echo "${BLUE}[INFO]${NC} Using temporary directory: ${GREEN}$TMP_DIR${NC}" -# Ensure the temporary directory is removed on exit. +# Ensure the branch is switched back and the temporary directory is removed on exit. function cleanup { custom_echo "${YELLOW}[CLEANUP]${NC} Switching back to original branch: ${GREEN}${CURRENT_BRANCH}${NC}..." git checkout "$CURRENT_BRANCH" || custom_echo "${RED}[ERROR]${NC} Failed to switch back to original branch." From ff74fd37323597994c1ff27db91dd12fa32bdb3c Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Wed, 19 Mar 2025 09:47:27 -0400 Subject: [PATCH 08/19] Update add command --- scripts/custom-publish.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/custom-publish.sh b/scripts/custom-publish.sh index 8dd2f58a7..b01e88821 100644 --- a/scripts/custom-publish.sh +++ b/scripts/custom-publish.sh @@ -77,8 +77,9 @@ cp -R "$TMP_DIR/." . # Stage and commit the changes. custom_echo "${BLUE}[DEPLOY]${NC} Staging files..." -# Use 'git add -f' to force-add files that are ignored by `.gitignore` -- particularly the `dist` directory. -git add -f . +# Use 'git add -f' to force-add files that are ignored by `.gitignore` +# - particularly the `dist` directory w/ out the `node_modules` directory. +git add -f dist/ ':!dist/node_modules' custom_echo "${BLUE}[DEPLOY]${NC} Committing build..." git commit -m "Auto commit -- publish custom build" From 43f5ef4af7179579936c82b84bec04e644622ec6 Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Wed, 19 Mar 2025 09:50:18 -0400 Subject: [PATCH 09/19] Update script --- scripts/custom-publish.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/custom-publish.sh b/scripts/custom-publish.sh index b01e88821..5d88aa3a1 100644 --- a/scripts/custom-publish.sh +++ b/scripts/custom-publish.sh @@ -27,8 +27,8 @@ if [ -n "$(git status --porcelain)" ]; then fi # Save the current branch name. -CURRENT_BRANCH=$(git symbolic-ref --short HEAD) -custom_echo "${BLUE}[INFO]${NC} Current branch: ${GREEN}${CURRENT_BRANCH}${NC}" +ORIGINAL_BRANCH=$(git symbolic-ref --short HEAD) +custom_echo "${BLUE}[INFO]${NC} Current branch: ${GREEN}${ORIGINAL_BRANCH}${NC}" # Create a temporary directory for the build output. TMP_DIR=$(mktemp -d -t custom-build-XXXXXXXX) @@ -36,8 +36,13 @@ custom_echo "${BLUE}[INFO]${NC} Using temporary directory: ${GREEN}$TMP_DIR${NC} # Ensure the branch is switched back and the temporary directory is removed on exit. function cleanup { - custom_echo "${YELLOW}[CLEANUP]${NC} Switching back to original branch: ${GREEN}${CURRENT_BRANCH}${NC}..." - git checkout "$CURRENT_BRANCH" || custom_echo "${RED}[ERROR]${NC} Failed to switch back to original branch." + CURRENT=$(git symbolic-ref --short HEAD) + if [ "$CURRENT" != "$ORIGINAL_BRANCH" ]; then + custom_echo "${YELLOW}[CLEANUP]${NC} Switching back to original branch: ${GREEN}${ORIGINAL_BRANCH}${NC}..." + git checkout "$ORIGINAL_BRANCH" || custom_echo "${RED}[ERROR]${NC} Failed to switch back to original branch." + else + custom_echo "${YELLOW}[CLEANUP]${NC} Already on the original branch: ${GREEN}${ORIGINAL_BRANCH}${NC}." + fi custom_echo "${YELLOW}[CLEANUP]${NC} Removing temporary directory..." rm -rf "$TMP_DIR" From a2dda55e22a1041af2923219a035de40a0bdd98e Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Wed, 19 Mar 2025 10:00:16 -0400 Subject: [PATCH 10/19] Update script --- scripts/custom-publish.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/custom-publish.sh b/scripts/custom-publish.sh index 5d88aa3a1..707039ec4 100644 --- a/scripts/custom-publish.sh +++ b/scripts/custom-publish.sh @@ -61,7 +61,8 @@ fi # Copy the built package to the temporary directory. custom_echo "${BLUE}[BUILD]${NC} Copying built package to temporary directory..." -cp -R packages/formik/. "$TMP_DIR/" +# copy everything, except the `node_modules` and `test` directories +rsync -av --exclude='node_modules/' --exclude='test/' packages/formik/ "$TMP_DIR/" # Check if the custom-build branch exists. If yes, checkout; if not, create it. if git rev-parse --verify custom-build >/dev/null 2>&1; then @@ -82,9 +83,8 @@ cp -R "$TMP_DIR/." . # Stage and commit the changes. custom_echo "${BLUE}[DEPLOY]${NC} Staging files..." -# Use 'git add -f' to force-add files that are ignored by `.gitignore` -# - particularly the `dist` directory w/ out the `node_modules` directory. -git add -f dist/ ':!dist/node_modules' +# Use 'git add -f' to force-add files that are ignored by `.gitignore` -- particularly the `dist` directory +git add -f dist/ custom_echo "${BLUE}[DEPLOY]${NC} Committing build..." git commit -m "Auto commit -- publish custom build" From bafcea9026a20c077df69c59fce3a74902ea5fc7 Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Wed, 19 Mar 2025 10:36:56 -0400 Subject: [PATCH 11/19] Add git add --- scripts/custom-publish.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/custom-publish.sh b/scripts/custom-publish.sh index 707039ec4..52a841717 100644 --- a/scripts/custom-publish.sh +++ b/scripts/custom-publish.sh @@ -83,6 +83,7 @@ cp -R "$TMP_DIR/." . # Stage and commit the changes. custom_echo "${BLUE}[DEPLOY]${NC} Staging files..." +git add . # Use 'git add -f' to force-add files that are ignored by `.gitignore` -- particularly the `dist` directory git add -f dist/ custom_echo "${BLUE}[DEPLOY]${NC} Committing build..." From b1e133946388754c9c9836042c3b1ebbafcbd51c Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Wed, 19 Mar 2025 10:47:29 -0400 Subject: [PATCH 12/19] Update script --- scripts/custom-publish.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/custom-publish.sh b/scripts/custom-publish.sh index 52a841717..4aa0f8196 100644 --- a/scripts/custom-publish.sh +++ b/scripts/custom-publish.sh @@ -61,8 +61,10 @@ fi # Copy the built package to the temporary directory. custom_echo "${BLUE}[BUILD]${NC} Copying built package to temporary directory..." -# copy everything, except the `node_modules` and `test` directories -rsync -av --exclude='node_modules/' --exclude='test/' packages/formik/ "$TMP_DIR/" +# copy everything from the built package to the temporary directory +cp -R packages/formik/. "$TMP_DIR/" +# delete the node_modules/ and test/ directories in the temporary directory +rm -rf "$TMP_DIR/node_modules" "$TMP_DIR/test" # Check if the custom-build branch exists. If yes, checkout; if not, create it. if git rev-parse --verify custom-build >/dev/null 2>&1; then From 3eba761ac4fa944005e75996cc18330c05ecb7c3 Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Wed, 19 Mar 2025 10:50:05 -0400 Subject: [PATCH 13/19] Update script --- scripts/custom-publish.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/custom-publish.sh b/scripts/custom-publish.sh index 4aa0f8196..881d5e4ae 100644 --- a/scripts/custom-publish.sh +++ b/scripts/custom-publish.sh @@ -73,6 +73,8 @@ if git rev-parse --verify custom-build >/dev/null 2>&1; then else custom_echo "${BLUE}[BRANCH]${NC} Branch 'custom-build' does not exist. Creating orphan branch..." git checkout --orphan custom-build + # add an initial empty commit to the branch + git commit --allow-empty -m "Initial commit" fi # Remove all files from the branch. From 2d22d51bf010cc1c8b839d515731f3511f0a06cb Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Wed, 19 Mar 2025 10:51:54 -0400 Subject: [PATCH 14/19] Update script --- scripts/custom-publish.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/custom-publish.sh b/scripts/custom-publish.sh index 881d5e4ae..f7d9fe1a0 100644 --- a/scripts/custom-publish.sh +++ b/scripts/custom-publish.sh @@ -54,8 +54,8 @@ custom_echo "${BLUE}[BUILD]${NC} Running build..." yarn build # Verify the build output exists. -if [ ! -d "packages/formik" ]; then - custom_echo "${RED}[ERROR]${NC} Build output directory 'packages/formik' does not exist. Exiting." +if [ ! -d "packages/formik/dist" ]; then + custom_echo "${RED}[ERROR]${NC} Build output directory 'packages/formik/dist' does not exist. Exiting." exit 1 fi From fb49e46246c1a898fc14a3075914fc16e66ab9e3 Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Wed, 19 Mar 2025 10:57:27 -0400 Subject: [PATCH 15/19] Also copy .git-ignore --- scripts/custom-publish.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/custom-publish.sh b/scripts/custom-publish.sh index f7d9fe1a0..a45ce034c 100644 --- a/scripts/custom-publish.sh +++ b/scripts/custom-publish.sh @@ -63,6 +63,8 @@ fi custom_echo "${BLUE}[BUILD]${NC} Copying built package to temporary directory..." # copy everything from the built package to the temporary directory cp -R packages/formik/. "$TMP_DIR/" +# copy the .git-ignore file to the temporary directory +cp .gitignore "$TMP_DIR/" # delete the node_modules/ and test/ directories in the temporary directory rm -rf "$TMP_DIR/node_modules" "$TMP_DIR/test" From 44b0659d60116f93cadbf6b3f2fe8edb5d0fe740 Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Wed, 19 Mar 2025 11:03:49 -0400 Subject: [PATCH 16/19] Add and use custom build so that it builds even if it detects no changes --- package.json | 1 + scripts/custom-publish.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3d0d7949f..673a029ba 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "e2e:ui": "playwright test --ui", "start:app": "turbo run build --filter formik... && yarn --cwd packages/formik link && yarn --cwd ./app link formik && yarn --cwd ./app && yarn --cwd ./app run dev", "benchmark": "tsx scripts/benchmark.tsx | tee output.txt", + "custom-build": "turbo run build --force", "custom-publish": "bash ./scripts/custom-publish.sh" }, "lint-staged": { diff --git a/scripts/custom-publish.sh b/scripts/custom-publish.sh index a45ce034c..0e90b3784 100644 --- a/scripts/custom-publish.sh +++ b/scripts/custom-publish.sh @@ -51,7 +51,7 @@ trap cleanup EXIT # Run the build. custom_echo "${BLUE}[BUILD]${NC} Running build..." -yarn build +yarn custom-build # Verify the build output exists. if [ ! -d "packages/formik/dist" ]; then From 8ea4f589b2b420881a042bc11d49c0045e0ef2f5 Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Wed, 19 Mar 2025 11:11:55 -0400 Subject: [PATCH 17/19] Add early return --- packages/formik/src/Formik.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/formik/src/Formik.tsx b/packages/formik/src/Formik.tsx index ea36e80d3..d3b241d48 100755 --- a/packages/formik/src/Formik.tsx +++ b/packages/formik/src/Formik.tsx @@ -687,6 +687,8 @@ export function useFormik({ const executeBlur = React.useCallback( (e: any, path?: string) => { + if (!e) return + if (e.persist) { e.persist(); } From 824071703cd2ee1790eae9cb12ee6a6539d3816b Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Wed, 19 Mar 2025 11:59:04 -0400 Subject: [PATCH 18/19] Update readme --- packages/formik/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/formik/README.md b/packages/formik/README.md index f8595d10f..55f12bec2 100644 --- a/packages/formik/README.md +++ b/packages/formik/README.md @@ -1,4 +1,8 @@ -# Formik Fork +# Formik Fork README + +This is a Fork of the original Formik repository. It is intended to be used as a dependency in other projects with minimal changes to address bugs, since the original repository is not actively maintained (as of March 2025). + +The `main` branch contains the original Formik codebase, while the `main-dev` branch is the main development branch for this fork. This Fork has a `custom-publish` script. @@ -13,7 +17,7 @@ yarn add git+https://github.com/zduvall/formik.git#custom-build ``` --- -# Formik Original Readme: +# Formik Original README

Formik.js From 49f69ccd4a4483aad28057669eb31daef0c27956 Mon Sep 17 00:00:00 2001 From: Zachary Duvall Date: Wed, 19 Mar 2025 12:05:22 -0400 Subject: [PATCH 19/19] Update readme --- packages/formik/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/formik/README.md b/packages/formik/README.md index 55f12bec2..731e97038 100644 --- a/packages/formik/README.md +++ b/packages/formik/README.md @@ -10,11 +10,13 @@ This Fork has a `custom-publish` script. yarn custom-publish ``` -This script builds the package and updates a dedicated `custom-build` branch containing only the distributable files. It then commits and force‑pushes these changes to GitHub, allowing you to continuously install the latest build with: +This should be called from the `main-dev` branch after making/merging changes to the codebase. The script builds the package and updates a dedicated `custom-build` branch containing only the distributable files. It then commits and force‑pushes these changes to GitHub, allowing you to continuously install the latest build with: ```bash yarn add git+https://github.com/zduvall/formik.git#custom-build ``` + +Note that the `custom-publish` script uses the `custom-build` script which forces a build even if there are no detected changes. --- # Formik Original README