diff --git a/shared/build-and-distribute.sh b/shared/build-and-distribute.sh index 30c8da8db..903ff683a 100755 --- a/shared/build-and-distribute.sh +++ b/shared/build-and-distribute.sh @@ -3,100 +3,20 @@ set -e # Stop on error set -u # Treat unset variables as errors -# Define the root path to your packages -PACKAGES_DIR="./" +# Make all build scripts executable +chmod +x ./identity-generator/build.sh +chmod +x ./password-generator/build.sh +chmod +x ./models/build.sh -# Define output targets and their file patterns for each package -declare -A IDENTITY_FILES -IDENTITY_FILES=( - ["index.js"]=1 - ["index.mjs"]=1 - ["index.d.ts"]=1 - ["index.js.map"]=1 - ["index.mjs.map"]=1 -) +# Run all build scripts +echo "🚀 Starting build process for all modules..." +cd ./identity-generator +./build.sh -declare -A PASSWORD_FILES -PASSWORD_FILES=( - ["index.js"]=1 - ["index.mjs"]=1 - ["index.d.ts"]=1 - ["index.js.map"]=1 - ["index.mjs.map"]=1 -) +cd ../password-generator +./build.sh -declare -A MODELS_FILES -MODELS_FILES=( - ["*.ts"]=1 - ["*.d.ts"]=1 -) +cd ../models +./build.sh -# Define output targets for each package -IDENTITY_TARGETS=( - "../apps/browser-extension/src/utils/shared/identity-generator" - "../apps/mobile-app/utils/shared/identity-generator" - "../apps/server/AliasVault.Client/wwwroot/js/shared/identity-generator" -) - -PASSWORD_TARGETS=( - "../apps/browser-extension/src/utils/shared/password-generator" - "../apps/mobile-app/utils/shared/password-generator" - "../apps/server/AliasVault.Client/wwwroot/js/shared/password-generator" -) - -MODELS_TARGETS=( - "../apps/browser-extension/src/utils/shared/models" -) - -# Build and distribute a package -build_and_copy() { - local package_name="$1" - shift - local targets=("$@") - local -n files_to_copy="$1" # Use nameref to access the associative array - - local package_path="$PACKAGES_DIR/$package_name" - - echo "📦 Building $package_name..." - (cd "$package_path" && npm install && npm run lint && npm run test && npm run build) - - local dist_path="$package_path/dist" - - for target in "${targets[@]}"; do - echo "📂 Copying $package_name → $target" - mkdir -p "$target" - - # Copy files based on the patterns defined in the associative array - for pattern in "${!files_to_copy[@]}"; do - if [[ "$pattern" == *"*"* ]]; then - # Handle wildcard patterns - find "$dist_path" -maxdepth 1 -name "$pattern" -exec cp {} "$target/" \; - else - # Handle specific files - if [ -f "$dist_path/$pattern" ]; then - cp "$dist_path/$pattern" "$target/" - fi - fi - done - - # Write README - cat > "$target/README.md" <