From ea387c0c9fd492b01b47c341f5a696f8a029a418 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 21 Sep 2025 11:22:26 -0400 Subject: [PATCH] Add automated versioning and deployment system --- deploy.sh | 3 + examples/keytest.html | 240 ++++++++++++++++++++++++++++++++ examples/login-and-profile.html | 2 + increment_build_push.sh | 107 ++++++++++++++ lite/VERSION | 1 + lite/build.js | 19 +++ lite/nostr-lite.js | 60 +++++--- lite/ui/modal.js | 56 +++++--- 8 files changed, 446 insertions(+), 42 deletions(-) create mode 100755 deploy.sh create mode 100644 examples/keytest.html create mode 100755 increment_build_push.sh create mode 100644 lite/VERSION diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..679e015 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +rsync -avz --progress lite/{nostr-lite.js,nostr.bundle.js} ubuntu@laantungir.net:WWW/nostr-login-lite/ diff --git a/examples/keytest.html b/examples/keytest.html new file mode 100644 index 0000000..ed7005a --- /dev/null +++ b/examples/keytest.html @@ -0,0 +1,240 @@ + + + + + + + Embedded NOSTR_LOGIN_LITE + + + + +
+
+ +
+ + +
+ + + + + + + + \ No newline at end of file diff --git a/examples/login-and-profile.html b/examples/login-and-profile.html index 242c161..159a6b7 100644 --- a/examples/login-and-profile.html +++ b/examples/login-and-profile.html @@ -49,6 +49,8 @@ try { await window.NOSTR_LOGIN_LITE.init({ + persistence: true, // Enable persistent authentication (default: true) + isolateSession: true, // Use sessionStorage for per-tab isolation (default: false = localStorage) theme: 'default', darkMode: false, methods: { diff --git a/increment_build_push.sh b/increment_build_push.sh new file mode 100755 index 0000000..0bcc8b3 --- /dev/null +++ b/increment_build_push.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +# increment_build_push.sh +# Automates version increment, build, and git operations + +set -e # Exit on any error + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +echo -e "${GREEN}🔄 Starting increment, build, and push process...${NC}" + +# Function to get the latest git tag +get_latest_tag() { + # Get the latest tag that matches the pattern v*.*.* + git tag -l "v*.*.*" | sort -V | tail -n1 +} + +# Function to increment version +increment_version() { + local version=$1 + # Remove 'v' prefix if present + version=${version#v} + + # Split version into parts + IFS='.' read -ra VERSION_PARTS <<< "$version" + + # Increment the patch version (last digit) + local major=${VERSION_PARTS[0]} + local minor=${VERSION_PARTS[1]} + local patch=${VERSION_PARTS[2]} + + patch=$((patch + 1)) + + echo "$major.$minor.$patch" +} + +# Step 1: Get current version +echo -e "${YELLOW}📋 Getting current version...${NC}" +current_tag=$(get_latest_tag) +if [ -z "$current_tag" ]; then + echo -e "${YELLOW}⚠️ No existing version tags found, starting with v0.1.0${NC}" + current_version="0.1.0" +else + echo -e "Current tag: ${current_tag}" + current_version=${current_tag#v} +fi + +# Step 2: Increment version +new_version=$(increment_version "$current_version") +new_tag="v$new_version" + +echo -e "${GREEN}📈 Incrementing version: $current_version → $new_version${NC}" + +# Step 2.5: Save version to lite/VERSION file +echo -e "${YELLOW}💾 Saving version to lite/VERSION...${NC}" +echo "$new_version" > lite/VERSION +echo -e "Version saved: ${GREEN}$new_version${NC}" + +# Step 2.5: Run build.js +echo -e "${YELLOW}🔧 Running build process...${NC}" +cd lite +node build.js +cd .. +echo -e "${GREEN}✅ Build completed${NC}" + +# Step 3: Git add +echo -e "${YELLOW}📦 Adding files to git...${NC}" +git add . + +# Step 4: Handle commit message and commit +commit_message="" +if [ $# -eq 0 ]; then + # No arguments provided, ask for commit message + echo -e "${YELLOW}💬 Please enter a commit message:${NC}" + read -p "> " commit_message + + if [ -z "$commit_message" ]; then + echo -e "${RED}❌ Commit message cannot be empty${NC}" + exit 1 + fi +else + # Use provided arguments as commit message + commit_message="$*" +fi + +echo -e "${YELLOW}💬 Committing changes...${NC}" +git commit -m "$commit_message" + +echo -e "${YELLOW}🏷️ Creating git tag: $new_tag${NC}" +git tag "$new_tag" + +# Step 5: Git push +echo -e "${YELLOW}🚀 Pushing to remote...${NC}" +git push +git push --tags + +echo -e "${GREEN}🎉 Successfully completed:${NC}" +echo -e " • Version incremented to: ${GREEN}$new_version${NC}" +echo -e " • VERSION file updated: ${GREEN}lite/VERSION${NC}" +echo -e " • Build completed: ${GREEN}lite/nostr-lite.js${NC}" +echo -e " • Git tag created: ${GREEN}$new_tag${NC}" +echo -e " • Changes pushed to remote${NC}" +echo -e "\n${GREEN}✨ Process complete!${NC}" \ No newline at end of file diff --git a/lite/VERSION b/lite/VERSION new file mode 100644 index 0000000..b1e80bb --- /dev/null +++ b/lite/VERSION @@ -0,0 +1 @@ +0.1.3 diff --git a/lite/build.js b/lite/build.js index c7ee131..af19f01 100644 --- a/lite/build.js +++ b/lite/build.js @@ -131,6 +131,25 @@ if (typeof window !== 'undefined') { let modalContent = fs.readFileSync(modalPath, 'utf8'); + // Read version from VERSION file and inject into modal title + const versionPath = path.join(__dirname, 'VERSION'); + let versionTitle = 'Nostr Login'; + + if (fs.existsSync(versionPath)) { + try { + const version = fs.readFileSync(versionPath, 'utf8').trim(); + versionTitle = `Nostr Login v${version}`; + console.log(`🔢 Using version: ${version}`); + } catch (error) { + console.warn('⚠️ Could not read VERSION file, using default title'); + } + } else { + console.log('📋 No VERSION file found, using default title'); + } + + // Replace the modal title in the content + modalContent = modalContent.replace(/modalTitle\.textContent = 'Nostr Login';/, `modalTitle.textContent = '${versionTitle}';`); + // Skip header comments let lines = modalContent.split('\n'); let contentStartIndex = 0; diff --git a/lite/nostr-lite.js b/lite/nostr-lite.js index ca61418..e02bfc0 100644 --- a/lite/nostr-lite.js +++ b/lite/nostr-lite.js @@ -8,7 +8,7 @@ * Two-file architecture: * 1. Load nostr.bundle.js (official nostr-tools bundle) * 2. Load nostr-lite.js (this file - NOSTR_LOGIN_LITE library with CSS-only themes) - * Generated on: 2025-09-20T19:25:01.143Z + * Generated on: 2025-09-21T15:22:26.408Z */ // Verify dependencies are loaded @@ -381,7 +381,7 @@ class Modal { `; const modalTitle = document.createElement('h2'); - modalTitle.textContent = 'Nostr Login'; + modalTitle.textContent = 'Nostr Login v0.1.3'; modalTitle.style.cssText = ` margin: 0; font-size: 24px; @@ -1253,24 +1253,28 @@ class Modal { nsecLabel.style.cssText = 'margin-bottom: 4px; font-size: 12px; font-weight: 600;'; const nsecContainer = document.createElement('div'); - nsecContainer.style.cssText = 'display: flex; align-items: flex-start; margin-bottom: 8px;'; + nsecContainer.style.cssText = 'margin-bottom: 8px;'; const nsecCode = document.createElement('code'); nsecCode.textContent = nsec; nsecCode.style.cssText = ` - flex: 1; - word-break: break-all; + display: block; + word-wrap: break-word; + overflow-wrap: break-word; background: #f3f4f6; padding: 6px; border-radius: 4px; font-size: 10px; line-height: 1.3; font-family: 'Courier New', monospace; - display: block; + margin-bottom: 4px; `; + const nsecCopyBtn = createCopyButton(nsec, 'nsec'); + nsecCopyBtn.style.cssText += 'display: inline-block; margin-left: 0;'; + nsecContainer.appendChild(nsecCode); - nsecContainer.appendChild(createCopyButton(nsec, 'nsec')); + nsecContainer.appendChild(nsecCopyBtn); nsecSection.appendChild(nsecLabel); nsecSection.appendChild(nsecContainer); @@ -1281,24 +1285,28 @@ class Modal { secretHexLabel.style.cssText = 'margin-bottom: 4px; font-size: 12px; font-weight: 600;'; const secretHexContainer = document.createElement('div'); - secretHexContainer.style.cssText = 'display: flex; align-items: flex-start; margin-bottom: 8px;'; + secretHexContainer.style.cssText = 'margin-bottom: 8px;'; const secretHexCode = document.createElement('code'); secretHexCode.textContent = secretKeyHex; secretHexCode.style.cssText = ` - flex: 1; - word-break: break-all; + display: block; + word-wrap: break-word; + overflow-wrap: break-word; background: #f3f4f6; padding: 6px; border-radius: 4px; font-size: 10px; line-height: 1.3; font-family: 'Courier New', monospace; - display: block; + margin-bottom: 4px; `; + const secretHexCopyBtn = createCopyButton(secretKeyHex, 'hex'); + secretHexCopyBtn.style.cssText += 'display: inline-block; margin-left: 0;'; + secretHexContainer.appendChild(secretHexCode); - secretHexContainer.appendChild(createCopyButton(secretKeyHex, 'hex')); + secretHexContainer.appendChild(secretHexCopyBtn); nsecSection.appendChild(secretHexLabel); nsecSection.appendChild(secretHexContainer); } @@ -1314,24 +1322,28 @@ class Modal { npubLabel.style.cssText = 'margin-bottom: 4px; font-size: 12px; font-weight: 600;'; const npubContainer = document.createElement('div'); - npubContainer.style.cssText = 'display: flex; align-items: flex-start; margin-bottom: 8px;'; + npubContainer.style.cssText = 'margin-bottom: 8px;'; const npubCode = document.createElement('code'); npubCode.textContent = npub; npubCode.style.cssText = ` - flex: 1; - word-break: break-all; + display: block; + word-wrap: break-word; + overflow-wrap: break-word; background: #f3f4f6; padding: 6px; border-radius: 4px; font-size: 10px; line-height: 1.3; font-family: 'Courier New', monospace; - display: block; + margin-bottom: 4px; `; + const npubCopyBtn = createCopyButton(npub, 'npub'); + npubCopyBtn.style.cssText += 'display: inline-block; margin-left: 0;'; + npubContainer.appendChild(npubCode); - npubContainer.appendChild(createCopyButton(npub, 'npub')); + npubContainer.appendChild(npubCopyBtn); npubSection.appendChild(npubLabel); npubSection.appendChild(npubContainer); @@ -1341,24 +1353,28 @@ class Modal { pubHexLabel.style.cssText = 'margin-bottom: 4px; font-size: 12px; font-weight: 600;'; const pubHexContainer = document.createElement('div'); - pubHexContainer.style.cssText = 'display: flex; align-items: flex-start;'; + pubHexContainer.style.cssText = ''; const pubHexCode = document.createElement('code'); pubHexCode.textContent = pubkeyHex; pubHexCode.style.cssText = ` - flex: 1; - word-break: break-all; + display: block; + word-wrap: break-word; + overflow-wrap: break-word; background: #f3f4f6; padding: 6px; border-radius: 4px; font-size: 10px; line-height: 1.3; font-family: 'Courier New', monospace; - display: block; + margin-bottom: 4px; `; + const pubHexCopyBtn = createCopyButton(pubkeyHex, 'hex'); + pubHexCopyBtn.style.cssText += 'display: inline-block; margin-left: 0;'; + pubHexContainer.appendChild(pubHexCode); - pubHexContainer.appendChild(createCopyButton(pubkeyHex, 'hex')); + pubHexContainer.appendChild(pubHexCopyBtn); npubSection.appendChild(pubHexLabel); npubSection.appendChild(pubHexContainer); diff --git a/lite/ui/modal.js b/lite/ui/modal.js index aa4b3fe..7046838 100644 --- a/lite/ui/modal.js +++ b/lite/ui/modal.js @@ -956,24 +956,28 @@ class Modal { nsecLabel.style.cssText = 'margin-bottom: 4px; font-size: 12px; font-weight: 600;'; const nsecContainer = document.createElement('div'); - nsecContainer.style.cssText = 'display: flex; align-items: flex-start; margin-bottom: 8px;'; + nsecContainer.style.cssText = 'margin-bottom: 8px;'; const nsecCode = document.createElement('code'); nsecCode.textContent = nsec; nsecCode.style.cssText = ` - flex: 1; - word-break: break-all; + display: block; + word-wrap: break-word; + overflow-wrap: break-word; background: #f3f4f6; padding: 6px; border-radius: 4px; font-size: 10px; line-height: 1.3; font-family: 'Courier New', monospace; - display: block; + margin-bottom: 4px; `; + const nsecCopyBtn = createCopyButton(nsec, 'nsec'); + nsecCopyBtn.style.cssText += 'display: inline-block; margin-left: 0;'; + nsecContainer.appendChild(nsecCode); - nsecContainer.appendChild(createCopyButton(nsec, 'nsec')); + nsecContainer.appendChild(nsecCopyBtn); nsecSection.appendChild(nsecLabel); nsecSection.appendChild(nsecContainer); @@ -984,24 +988,28 @@ class Modal { secretHexLabel.style.cssText = 'margin-bottom: 4px; font-size: 12px; font-weight: 600;'; const secretHexContainer = document.createElement('div'); - secretHexContainer.style.cssText = 'display: flex; align-items: flex-start; margin-bottom: 8px;'; + secretHexContainer.style.cssText = 'margin-bottom: 8px;'; const secretHexCode = document.createElement('code'); secretHexCode.textContent = secretKeyHex; secretHexCode.style.cssText = ` - flex: 1; - word-break: break-all; + display: block; + word-wrap: break-word; + overflow-wrap: break-word; background: #f3f4f6; padding: 6px; border-radius: 4px; font-size: 10px; line-height: 1.3; font-family: 'Courier New', monospace; - display: block; + margin-bottom: 4px; `; + const secretHexCopyBtn = createCopyButton(secretKeyHex, 'hex'); + secretHexCopyBtn.style.cssText += 'display: inline-block; margin-left: 0;'; + secretHexContainer.appendChild(secretHexCode); - secretHexContainer.appendChild(createCopyButton(secretKeyHex, 'hex')); + secretHexContainer.appendChild(secretHexCopyBtn); nsecSection.appendChild(secretHexLabel); nsecSection.appendChild(secretHexContainer); } @@ -1017,24 +1025,28 @@ class Modal { npubLabel.style.cssText = 'margin-bottom: 4px; font-size: 12px; font-weight: 600;'; const npubContainer = document.createElement('div'); - npubContainer.style.cssText = 'display: flex; align-items: flex-start; margin-bottom: 8px;'; + npubContainer.style.cssText = 'margin-bottom: 8px;'; const npubCode = document.createElement('code'); npubCode.textContent = npub; npubCode.style.cssText = ` - flex: 1; - word-break: break-all; + display: block; + word-wrap: break-word; + overflow-wrap: break-word; background: #f3f4f6; padding: 6px; border-radius: 4px; font-size: 10px; line-height: 1.3; font-family: 'Courier New', monospace; - display: block; + margin-bottom: 4px; `; + const npubCopyBtn = createCopyButton(npub, 'npub'); + npubCopyBtn.style.cssText += 'display: inline-block; margin-left: 0;'; + npubContainer.appendChild(npubCode); - npubContainer.appendChild(createCopyButton(npub, 'npub')); + npubContainer.appendChild(npubCopyBtn); npubSection.appendChild(npubLabel); npubSection.appendChild(npubContainer); @@ -1044,24 +1056,28 @@ class Modal { pubHexLabel.style.cssText = 'margin-bottom: 4px; font-size: 12px; font-weight: 600;'; const pubHexContainer = document.createElement('div'); - pubHexContainer.style.cssText = 'display: flex; align-items: flex-start;'; + pubHexContainer.style.cssText = ''; const pubHexCode = document.createElement('code'); pubHexCode.textContent = pubkeyHex; pubHexCode.style.cssText = ` - flex: 1; - word-break: break-all; + display: block; + word-wrap: break-word; + overflow-wrap: break-word; background: #f3f4f6; padding: 6px; border-radius: 4px; font-size: 10px; line-height: 1.3; font-family: 'Courier New', monospace; - display: block; + margin-bottom: 4px; `; + const pubHexCopyBtn = createCopyButton(pubkeyHex, 'hex'); + pubHexCopyBtn.style.cssText += 'display: inline-block; margin-left: 0;'; + pubHexContainer.appendChild(pubHexCode); - pubHexContainer.appendChild(createCopyButton(pubkeyHex, 'hex')); + pubHexContainer.appendChild(pubHexCopyBtn); npubSection.appendChild(pubHexLabel); npubSection.appendChild(pubHexContainer);