FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
dinavinter
dinavinteros
Public
Like
os
Home
Code
18
accountviewer
2
dsviewer
2
shared
1
README-author-update.md
README-delete-test-projects.md
accounts-schema.ts
accounts.yaml
cleanup.tsx
copy-projects-tods.ts
data.json
delete-test-projects-advanced.ts
delete-test-projects.ts
ds-schema.ts
ds.md
main.tsx
update-authors-advanced.ts
update-project-authors.ts
verify
Branches
1
Pull requests
Remixes
History
Environment variables
5
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README-delete-test-projects.md
Code
/
README-delete-test-projects.md
Search
6/6/2025
Viewing readonly version of main branch: v163
View latest version
README-delete-test-projects.md

Test Project Deletion Scripts

This directory contains scripts to safely delete projects with titles that are "test" or start with "test" from Gigya DS.

Scripts

1. delete-test-projects.ts (Basic Version)

A straightforward script that deletes test projects with minimal configuration.

Features:

  • Identifies projects with titles matching "test" patterns
  • Soft deletes projects (marks as deleted rather than permanent removal)
  • Provides summary statistics and verification

2. delete-test-projects-advanced.ts (Advanced Version)

A comprehensive script with extensive safety features and configuration options.

Features:

  • Dry run mode to preview deletions
  • Confirmation prompts for safety
  • Flexible matching patterns (exact match, starts with, custom patterns)
  • Case sensitivity options
  • Batch processing with rate limiting
  • Detailed analysis and reporting
  • Comprehensive verification

⚠️ Safety Notice

IMPORTANT: These scripts perform soft deletes by marking projects as deleted: true rather than permanently removing them from the database. This allows for potential recovery if needed.

Prerequisites

  1. Environment Variables:

    export GIGYA_API_KEY="your_api_key" export GIGYA_APP_KEY="your_app_key" export GIGYA_APP_SECRET="your_app_secret" export GIGYA_DOMAIN="accounts.eu1.gigya.com" # Optional, defaults to EU1
  2. Permissions:

    • Ensure your Gigya credentials have write access to the oss_projects data store

Usage

Basic Script

# Delete all test projects (basic version) npx tsx delete-test-projects.ts

Advanced Script

Preview Deletions (Recommended First Step)

# Preview what would be deleted without making changes DRY_RUN=true npx tsx delete-test-projects-advanced.ts

Delete with Confirmation

# Delete test projects with confirmation prompt CONFIRM_DELETE=DELETE npx tsx delete-test-projects-advanced.ts

Delete Without Confirmation

# Delete test projects without confirmation (use with caution!) REQUIRE_CONFIRMATION=false npx tsx delete-test-projects-advanced.ts

Case Sensitive Matching

# Only match "Test" with exact case CASE_SENSITIVE=true npx tsx delete-test-projects-advanced.ts

Exact Match Only

# Only delete projects with title exactly "test" EXACT_MATCH_ONLY=true npx tsx delete-test-projects-advanced.ts

Custom Patterns

# Delete projects matching custom patterns CUSTOM_PATTERNS="demo,sample,temp" npx tsx delete-test-projects-advanced.ts

Configuration Options (Advanced Script)

Environment VariableDefaultDescription
DRY_RUNfalsePreview deletions without executing them
REQUIRE_CONFIRMATIONtrueRequire manual confirmation before deletion
CASE_SENSITIVEfalseUse case-sensitive title matching
EXACT_MATCH_ONLYfalseOnly delete exact "test" matches, not "test*"
CUSTOM_PATTERNS""Comma-separated additional patterns to match
CONFIRM_DELETE""Set to "DELETE" to confirm deletion

Matching Patterns

Default Behavior (Case Insensitive)

The scripts will delete projects with titles that:

  • Are exactly "test" (case insensitive)
  • Start with "test" (case insensitive)

Examples of matched titles:

  • test
  • Test
  • TEST
  • test project
  • Test Application
  • testing something

Exact Match Only

With EXACT_MATCH_ONLY=true, only projects with title exactly "test" will be deleted.

Custom Patterns

You can specify additional patterns to match:

CUSTOM_PATTERNS="demo,sample,temp,prototype"

This will also delete projects containing these words in their titles.

Output Examples

Analysis Phase

🔍 Analyzing projects for test patterns...

📊 Project Analysis:
   📁 Total active projects: 25
   🧪 Test projects found: 3
   🎯 Exact 'test' matches: 1
   🔤 Starts with 'test': 2
   🔧 Custom pattern matches: 0

📋 Projects that will be deleted:
   1. "test" - Exact match: 'test'
      👤 Author: User I123456
      📅 Created: 12/3/2024
   2. "test project" - Starts with 'test'
      👤 Author: Developer
      📅 Created: 12/2/2024

Deletion Phase

🗑️  Starting test project deletion...

📦 Processing batch 1/1

🔄 Deleting "test"
   📝 Reason: Exact match: 'test'
   ✅ Successfully deleted

📊 Final Deletion Report:
✅ Successfully deleted: 3 projects
❌ Errors: 0 projects
📈 Success rate: 100.0%

Safety Features

1. Dry Run Mode

  • Preview all changes before execution
  • See exactly which projects would be deleted
  • No actual modifications made

2. Confirmation Prompts

  • Manual confirmation required by default
  • Must type "DELETE" exactly to proceed
  • Can be disabled for automation

3. Soft Deletion

  • Projects marked as deleted: true
  • Original data preserved
  • Can potentially be recovered

4. Batch Processing

  • Processes projects in small batches
  • Rate limiting to prevent API overload
  • Graceful error handling

5. Comprehensive Verification

  • Confirms deletions were successful
  • Reports any remaining test projects
  • Shows before/after statistics

Recovery

If you need to recover deleted projects:

# Find deleted test projects # You would need to create a recovery script that: # 1. Searches for projects with deleted=true # 2. Filters for test projects # 3. Sets deleted=false to restore them

Troubleshooting

1. No Projects Found

✅ No test projects found to delete.
  • Verify projects exist with test-like titles
  • Check case sensitivity settings
  • Ensure projects aren't already deleted

2. Permission Errors

❌ Failed to delete: Access denied
  • Verify Gigya credentials have write permissions
  • Check API key, app key, and secret are correct
  • Ensure you have access to the oss_projects data store

3. Confirmation Issues

❌ Deletion not confirmed. Exiting.
  • Set CONFIRM_DELETE=DELETE environment variable
  • Or use REQUIRE_CONFIRMATION=false to skip confirmation

4. Rate Limiting

❌ Error: Too many requests
  • The script includes built-in rate limiting
  • If issues persist, increase delay between requests
  • Process smaller batches

Best Practices

  1. Always start with dry run:

    DRY_RUN=true npx tsx delete-test-projects-advanced.ts
  2. Review the analysis carefully:

    • Check the list of projects to be deleted
    • Verify no legitimate projects are included
    • Pay attention to author and creation date
  3. Use confirmation for safety:

    • Keep REQUIRE_CONFIRMATION=true for manual operations
    • Only disable for trusted automated processes
  4. Test with exact match first:

    EXACT_MATCH_ONLY=true DRY_RUN=true npx tsx delete-test-projects-advanced.ts
  5. Backup considerations:

    • Consider exporting project data before deletion
    • Soft deletes allow recovery, but backup is safer

Integration with Other Scripts

These deletion scripts work well with other project management scripts:

  1. After data imports: Clean up test projects created during development
  2. Before production: Remove test data before going live
  3. Regular maintenance: Periodic cleanup of test projects

Example Workflows

Development Cleanup

# 1. Preview what would be deleted DRY_RUN=true npx tsx delete-test-projects-advanced.ts # 2. Delete exact "test" matches only EXACT_MATCH_ONLY=true CONFIRM_DELETE=DELETE npx tsx delete-test-projects-advanced.ts # 3. Delete all test projects CONFIRM_DELETE=DELETE npx tsx delete-test-projects-advanced.ts

Automated Cleanup

# For CI/CD or automated environments REQUIRE_CONFIRMATION=false CUSTOM_PATTERNS="temp,demo" npx tsx delete-test-projects-advanced.ts

Conservative Cleanup

# Very careful deletion - exact matches only, case sensitive EXACT_MATCH_ONLY=true CASE_SENSITIVE=true CONFIRM_DELETE=DELETE npx tsx delete-test-projects-advanced.ts
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.