From db96f17d447ca710bf40e67c90ceee2a74fb763b Mon Sep 17 00:00:00 2001 From: Sarah Schwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Wed, 22 May 2024 08:53:09 -0600 Subject: [PATCH] bump nightly versions, fixes (#279) --- .../quickstart/building-a-smart-contract.mdx | 4 +- docs/nightly/builds/sway | 2 +- docs/nightly/fuels-rs | 2 +- docs/nightly/fuels-ts | 2 +- docs/nightly/fuels-wallet | 2 +- docs/nightly/sway | 2 +- package.json | 4 +- scripts/clean-build-files.mjs | 114 ++++++++++++++++++ scripts/clean-build-files.sh | 57 --------- 9 files changed, 123 insertions(+), 66 deletions(-) create mode 100644 scripts/clean-build-files.mjs delete mode 100644 scripts/clean-build-files.sh diff --git a/docs/guides/docs/quickstart/building-a-smart-contract.mdx b/docs/guides/docs/quickstart/building-a-smart-contract.mdx index c60753947..1ff105005 100644 --- a/docs/guides/docs/quickstart/building-a-smart-contract.mdx +++ b/docs/guides/docs/quickstart/building-a-smart-contract.mdx @@ -64,11 +64,11 @@ fuelup default latest ```sh -pnpm create fuels@82.0 +pnpm create fuels@0.82.0 ``` ```sh -npm create fuels@82.0 +npm create fuels@0.82.0 ``` diff --git a/docs/nightly/builds/sway b/docs/nightly/builds/sway index 4cd84089c..5cc814a84 160000 --- a/docs/nightly/builds/sway +++ b/docs/nightly/builds/sway @@ -1 +1 @@ -Subproject commit 4cd84089c616b3ad88ee6151209e4b34d5c9ab7f +Subproject commit 5cc814a84edf1d13dc5dcb12f782e4f997250109 diff --git a/docs/nightly/fuels-rs b/docs/nightly/fuels-rs index b5f563e90..0a95de88b 160000 --- a/docs/nightly/fuels-rs +++ b/docs/nightly/fuels-rs @@ -1 +1 @@ -Subproject commit b5f563e9051c3cac0edb8f18137069e870f6cb31 +Subproject commit 0a95de88b57c7a604ee488a61cdf76b2dafbf615 diff --git a/docs/nightly/fuels-ts b/docs/nightly/fuels-ts index 75e8f6b59..cb5ce1594 160000 --- a/docs/nightly/fuels-ts +++ b/docs/nightly/fuels-ts @@ -1 +1 @@ -Subproject commit 75e8f6b59834f0ad6b284634de11bd8a9cb90f41 +Subproject commit cb5ce1594d4c35ee342cf80b3e24c61537b16add diff --git a/docs/nightly/fuels-wallet b/docs/nightly/fuels-wallet index 7ac8f7c2e..ca83b8c3b 160000 --- a/docs/nightly/fuels-wallet +++ b/docs/nightly/fuels-wallet @@ -1 +1 @@ -Subproject commit 7ac8f7c2eacd4b4f25d10fc79e5125307bd91aeb +Subproject commit ca83b8c3bb84d6791120279f042ed5866bddbbcc diff --git a/docs/nightly/sway b/docs/nightly/sway index b495d0df6..d9985d811 160000 --- a/docs/nightly/sway +++ b/docs/nightly/sway @@ -1 +1 @@ -Subproject commit b495d0df6956524fd68dab7e062df04d2e581ac3 +Subproject commit d9985d8111f94235edba9a08fc71a9513ec2a95c diff --git a/package.json b/package.json index a5bb16fee..883bffa0c 100644 --- a/package.json +++ b/package.json @@ -4,14 +4,14 @@ "private": true, "scripts": { "build": "next build", - "build:ci": "run-s docs:clean docs:sync generate:* patch:wallet build", + "build:ci": "run-s docs:sync docs:clean generate:* patch:wallet build", "build:content": "contentlayer build", "check": "run-s lint", "check:prod": "run-s lint:prod", "copy:icons": "cp -r ./node_modules/@fuel-ui/icons/dist/icons/sprite.svg ./public/icons", "deps:update": "updates -gu", "dev": "./scripts/dev.sh", - "docs:clean": "sh ./scripts/clean-build-files.sh", + "docs:clean": "node ./scripts/clean-build-files.mjs", "docs:sync": "sh ./scripts/sync-repos.sh", "docs:update": "node scripts/update-nightly/index.mjs", "docs:update:nightly": "node scripts/update-nightly/index.mjs --nightly", diff --git a/scripts/clean-build-files.mjs b/scripts/clean-build-files.mjs new file mode 100644 index 000000000..505b9dda1 --- /dev/null +++ b/scripts/clean-build-files.mjs @@ -0,0 +1,114 @@ +import fs from 'fs'; +import path from 'path'; + +// List of directories to delete unused files from +const targetDirs = [ + './docs/sway', + './docs/nightly/sway', + './docs/builds/sway', + './docs/nightly/builds/sway', + './docs/fuels-rs', + './docs/nightly/fuels-rs', + './docs/fuels-ts', + './docs/nightly/fuels-ts', + './docs/fuels-wallet', + './docs/nightly/fuels-wallet', + './docs/fuel-graphql-docs', + './docs/nightly/fuel-graphql-docs', + // './docs/fuel-core', +]; + +// Exclusions for each type of directory +const exclusions = { + sway: [ + 'sway/Cargo.toml', + 'sway/forc-pkg', + 'sway/sway-lib-std', + 'sway/docs/book/src', + 'sway/examples', + 'sway/master/book', + 'sway/test/src/sdk-harness/test_projects/run_external_proxy', + 'sway/test/src/sdk-harness/test_projects/run_external_target', + ], + fuels_rs: [ + 'fuels-rs/Cargo.toml', + 'fuels-rs/docs', + 'fuels-rs/examples', + 'fuels-rs/packages', + 'fuels-rs/e2e', + ], + fuels_ts: [ + 'fuels-ts/apps', + 'fuels-ts/packages', + 'fuels-ts/package.json', + 'fuels-ts/demo-wallet-sdk-react', + ], + fuels_wallet: ['fuels-wallet/package.json', 'fuels-wallet/packages'], + // fuel_core: ['fuel-core/deployment/scripts/chainspec', 'fuel-core/Cargo.toml'], + fuel_graphql_docs: [ + 'fuel-graphql-docs/docs', + 'fuel-graphql-docs/examples', + 'fuel-graphql-docs/src', + ], +}; + +function main() { + for (const targetDir of targetDirs) { + if (!fs.existsSync(targetDir)) { + // console.log(`Directory ${targetDir} does not exist!`); + const basePath = process.cwd(); + // console.log(`Current directory: ${basePath}`); + return; + } + // Change to the target directory + process.chdir(targetDir); + const dirBasename = path.basename(targetDir).replace(/-/g, '_'); + const currentExclusions = exclusions[dirBasename]; + cleanupFiles(currentExclusions, '.'); + // console.log(`Cleanup done for ${targetDir}!`); + // Return to the original directory + let x = '../..'; + if (process.cwd().includes('nightly')) { + x = `${x}/..`; + } + if (process.cwd().includes('builds')) { + x = `${x}/..`; + } + process.chdir(path.resolve(process.cwd(), x)); + } +} + +function cleanupFiles(currentExclusions, dirPath) { + // Read all items in directory + fs.readdirSync(dirPath).forEach((item) => { + let shouldDelete = true; + const basePath = process.cwd().split('/docs/')[1]; + const thisFilePath = path + .join(basePath, dirPath, item) + .replace('builds/', '') + .replace('nightly/', ''); + const subFilePath = `./${thisFilePath.split('/').slice(1).join('/')}`; + + if (currentExclusions?.includes(thisFilePath)) { + shouldDelete = false; + // console.log('Excluding: ', thisFilePath); + } else if ( + fs.existsSync(subFilePath) && + fs.lstatSync(subFilePath).isDirectory() + ) { + shouldDelete = false; + cleanupFiles(currentExclusions, subFilePath); + } + + deleteFolder(shouldDelete, subFilePath); + }); +} + +function deleteFolder(shouldDelete, subFilePath) { + if (shouldDelete) { + // console.log('DELETING: ', subFilePath); + fs.rmSync(subFilePath, { recursive: true, force: true }); + } +} + +main(); diff --git a/scripts/clean-build-files.sh b/scripts/clean-build-files.sh deleted file mode 100644 index cd6c8e42a..000000000 --- a/scripts/clean-build-files.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -# List of directories to delete unused files from -TARGET_DIRS=( -"./docs/sway" -"./docs/nightly/sway" -"./docs/builds/sway" -"./docs/nightly/builds/sway" -"./docs/fuelup" -"./docs/fuels-rs" -"./docs/nightly/fuels-rs" -"./docs/fuels-ts" -"./docs/nightly/fuels-ts" -"./docs/fuels-wallet" -"./docs/nightly/fuels-wallet" -) - -# File/folder names to exclude from deletion in each book -EXCLUSIONS_sway=("Cargo.toml" "forc-pkg" "sway-lib-std" "docs" "examples" "master") -EXCLUSIONS_fuels_rs=("Cargo.toml" "docs" "examples" "packages") -EXCLUSIONS_fuels_ts=("apps" "packages" "package.json", "demo-wallet-sdk-react") -EXCLUSIONS_fuels_wallet=("package.json" "packages") - -for TARGET_DIR in "${TARGET_DIRS[@]}"; do - # Check if directory exists - if [[ ! -d "$TARGET_DIR" ]]; then - echo "Warning: Target directory $TARGET_DIR does not exist. Skipping..." - continue - fi - - # Change to the target directory, pushing to directory stack - pushd "$TARGET_DIR" > /dev/null - - for item in *; do - should_delete=true - - dir_basename=$(basename "$TARGET_DIR" | tr '-' '_') - current_exclusions="EXCLUSIONS_$dir_basename[@]" - - for exclusion in "${!current_exclusions}"; do - if [[ "$item" == "$exclusion" ]]; then - should_delete=false - break - fi - done - - if $should_delete; then - rm -rf "$item" - # echo "DELETED: $item" - fi - done - - echo "Cleanup done for $TARGET_DIR!" - - # Return to the original directory, popping from directory stack - popd > /dev/null -done