diff --git a/.cargo/config.toml b/.cargo/config.toml index 3c31adf..1ac4a86 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -4,24 +4,13 @@ jobs = 8 rustdocflags = ["--cfg", "docsrs"] rustflags = [] -[target.x86_64-unknown-linux-gnu] -rustflags = ["-C", "target-feature=+sse2"] - [target.aarch64-apple-darwin] rustflags = [] -[target.aarch64-unknown-linux-gnu] -linker = "aarch64-linux-gnu-gcc" -rustflags = [] - [target.aarch64-unknown-linux-musl] linker = "aarch64-linux-musl-gcc" rustflags = ["-C", "target-feature=-crt-static", "-C", "link-arg=-lgcc"] -[target.armv7-unknown-linux-gnueabihf] -linker = "arm-linux-gnueabihf-gcc" -rustflags = [] - [target.aarch64-linux-android] rustflags = [] @@ -33,4 +22,7 @@ linker = "rust-lld" rustflags = [] [target.wasm32-unknown-unknown] -rustflags = [] \ No newline at end of file +rustflags = [] + +[target.arm-unknown-linux-musleabi] +linker = "arm-linux-gnueabi-gcc" \ No newline at end of file diff --git a/.github/foo.ts b/.github/foo.ts new file mode 100644 index 0000000..4577182 --- /dev/null +++ b/.github/foo.ts @@ -0,0 +1,23 @@ +export type SimpleGraph = Map; + +export const breadthFirstSearch = (graph: SimpleGraph, start: T): T[] => { + let bfsOrder: T[] = []; + + const bfs = (queue: T[], visited: Set) => { + if (queue.length === 0) return; + + const [node, ...rest] = queue; + bfsOrder = [...bfsOrder, node]; + + const unvisitedNeighbors = + graph.get(node)?.filter((neighbor) => !visited.has(neighbor)) || []; + const newQueue = [...rest, ...unvisitedNeighbors]; + const newVisited = new Set([...visited, ...unvisitedNeighbors]); + + bfs(newQueue, newVisited); + }; + + bfs([start], new Set([start])); + + return bfsOrder; +}; diff --git a/.github/verdaccio-config.yml b/.github/verdaccio-config.yml new file mode 100644 index 0000000..fd68fff --- /dev/null +++ b/.github/verdaccio-config.yml @@ -0,0 +1,24 @@ +auth: + auth-memory: + users: + foo: + name: test + password: test +store: + memory: + limit: 1000 +## we don't need any remote request +uplinks: +packages: + '@*/*': + access: $all + publish: $all + '**': + access: $all + publish: $all +middlewares: + audit: + enabled: true +max_body_size: 100mb +log: + - {type: stdout, format: pretty, level: trace} \ No newline at end of file diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml deleted file mode 100644 index f13fa06..0000000 --- a/.github/workflows/CI.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Rust CI/CD - -on: - push: - branches: [main] - pull_request: - branches: ['*'] - -env: - CARGO_TERM_COLOR: always - CARGO_INCREMENTAL: 0 - -jobs: - test_rust_crate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - - name: Basic build validation - run: | - cargo build - - - name: Check program - run: | - cargo check - - - name: Check formatting - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - - name: Run tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --all-features - - - name: Output test coverage - run: | - cargo install cargo-tarpaulin - cargo tarpaulin --fail-under 75 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5a2e248 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,153 @@ +name: Build Binaries & Upload Artifacts + +on: workflow_call + +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: 0 + +jobs: + upload_assets_macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: rustfmt, clippy + target: x86_64-apple-darwin + default: true + + - name: Install dependencies + run: brew install llvm + + - name: Build x86_64-apple-darwin + run: cargo build --release --target=x86_64-apple-darwin + + - name: Setup Rust for aarch64-apple-darwin + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: aarch64-apple-darwin + default: true + + - name: Build aarch64-apple-darwin + run: cargo build --release --target=aarch64-apple-darwin + + - name: Set permissions for macOS binaries + run: | + chmod +x target/x86_64-apple-darwin/release/fta + chmod +x target/aarch64-apple-darwin/release/fta + + - name: Create tarballs and move binaries + run: | + tar czvf x86_64-apple-darwin.tar.gz -C target/x86_64-apple-darwin/release fta + tar czvf aarch64-apple-darwin.tar.gz -C target/aarch64-apple-darwin/release fta + + - name: Upload binaries as artifacts + uses: actions/upload-artifact@v2 + with: + name: macos-binaries + path: | + *.tar.gz + + upload_assets_windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup Rust for x86_64-pc-windows-msvc + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: rustfmt, clippy + target: x86_64-pc-windows-msvc + default: true + override: true + + - name: Build x86_64-pc-windows-msvc + run: cargo build --release --target=x86_64-pc-windows-msvc + + - name: Setup Rust for aarch64-pc-windows-msvc + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: aarch64-pc-windows-msvc + default: true + override: true + + - name: Build aarch64-pc-windows-msvc + run: cargo build --release --target=aarch64-pc-windows-msvc + + - name: Create zipfiles and move binaries + shell: pwsh + run: | + Compress-Archive -Path target/x86_64-pc-windows-msvc/release/fta.exe -DestinationPath x86_64-pc-windows-msvc.zip + Compress-Archive -Path target/aarch64-pc-windows-msvc/release/fta.exe -DestinationPath aarch64-pc-windows-msvc.zip + + - name: Upload binaries as artifacts + uses: actions/upload-artifact@v2 + with: + name: windows-binaries + path: | + *.zip + + upload_assets_linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Update packages + run: sudo apt-get update + + - name: Install aarch64 dependencies + run: sudo apt-get install -y gcc-aarch64-linux-gnu libc6-dev-arm64-cross + + - name: Install aarch64-unknown-linux-musl dependencies + run: | + sudo apt-get install -y musl-tools + sudo apt-get install gcc-arm-linux-gnueabi + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: rustfmt, clippy + profile: minimal + target: x86_64-unknown-linux-musl + + - name: Add Rust targets + run: | + rustup target add x86_64-unknown-linux-musl + rustup target add aarch64-unknown-linux-musl + rustup target add arm-unknown-linux-musleabi + + - name: Install MUSL toolchain for AArch64 + run: | + wget -q https://musl.cc/aarch64-linux-musl-cross.tgz + tar -xf aarch64-linux-musl-cross.tgz + echo "$(pwd)/aarch64-linux-musl-cross/bin" >> $GITHUB_PATH + + - name: Build and tarball + run: | + TARGETS=( + x86_64-unknown-linux-musl + aarch64-unknown-linux-musl + arm-unknown-linux-musleabi + ) + + for TARGET in "${TARGETS[@]}"; do + echo "Building for $TARGET" + cargo build --release --target="$TARGET" + chmod +x target/${TARGET}/release/fta + tar czf "${TARGET}.tar.gz" -C "./target/${TARGET}/release/" fta + done + + - name: Upload binaries as artifacts + uses: actions/upload-artifact@v2 + with: + name: linux-binaries + path: | + *.tar.gz diff --git a/.github/workflows/publish-dry-run.yml b/.github/workflows/publish-dry-run.yml new file mode 100644 index 0000000..b94905a --- /dev/null +++ b/.github/workflows/publish-dry-run.yml @@ -0,0 +1,98 @@ +name: Publish NPM Package (Dry Run) + +on: workflow_call + +jobs: + publish_fta_cli_dry_run: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Node.js environment + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Download macOS artifacts + uses: actions/download-artifact@v2 + with: + name: macos-binaries + path: artifact/ + + - name: Download linux artifacts + uses: actions/download-artifact@v2 + with: + name: linux-binaries + path: artifact/ + + - name: Download windows artifacts + uses: actions/download-artifact@v2 + with: + name: windows-binaries + path: artifact/ + + - name: Extract nix artifacts + run: | + for file in artifact/*.tar.gz; do + base=$(basename -- "$file") + dirname="${base%%.*}" + mkdir -p packages/fta/binaries/"$dirname" + tar -xzf "$file" -C packages/fta/binaries/"$dirname" + done + + - name: Extract artifacts + run: | + for file in artifact/*.zip; do + dir=$(basename "$file" .zip) + mkdir -p "packages/fta/binaries/$dir" + unzip -o "$file" -d "packages/fta/binaries/$dir" + done + + # List out the binaries dir + ls -R packages/fta/binaries/ + + - name: Install Verdaccio + run: npm install -g verdaccio verdaccio-memory verdaccio-auth-memory + + - name: Setup Verdaccio Config + run: | + mkdir -p $HOME/.config/verdaccio + cp .github/verdaccio-config.yml $HOME/.config/verdaccio/config.yml + + - name: Start Verdaccio + run: | + npx verdaccio --config $HOME/.config/verdaccio/config.yml --listen 4873 & + sleep 10 + + - name: Publish package + run: | + npm config set registry http://localhost:4873/ + npm config set //localhost:4873/:_authToken "$(echo -n 'test:test' | base64)" + cd packages/fta + npm publish --registry http://localhost:4873 + cd ../ + + - name: Install and check package + run: | + # Install FTA via the CLI package + npm install fta-cli --registry http://localhost:4873 + + # Verify the output is what we expect + sudo apt-get install -y jq + EXPECTED_OUTPUT=$(cat <<'EOF' + [{"file_name":"foo.ts","cyclo":3,"halstead":{"uniq_operators":13,"uniq_operands":21,"total_operators":39,"total_operands":44,"program_length":34,"vocabulary_size":83,"volume":216.75134066579542,"difficulty":9.068181818181818,"effort":1965.5405664920995,"time":109.19669813844997,"bugs":0.07225044688859847},"line_count":23,"fta_score":42.65462143345264,"assessment":"OK"}] + EOF + ) + OUTPUT=$(npx fta-cli .github --json) + if [ "$(echo "$OUTPUT" | jq --sort-keys '.')" == "$(echo "$EXPECTED_OUTPUT" | jq --sort-keys '.')" ]; then + echo "$OUTPUT" + echo "Output matches expected" + else + echo "Output does not match expected." + echo "Expected:" + echo "$EXPECTED_OUTPUT" + echo "Got:" + echo "$OUTPUT" + exit 1 + fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 12fd0ac..2912bb6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,39 +40,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup Rust - uses: actions-rs/toolchain@v1 + - name: Download macOS artifact + uses: actions/download-artifact@v2 with: - toolchain: stable - components: rustfmt, clippy - target: x86_64-apple-darwin - default: true - - - name: Install dependencies - run: brew install llvm - - - name: Build x86_64-apple-darwin - run: cargo build --release --target=x86_64-apple-darwin - - - name: Setup Rust for aarch64-apple-darwin - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - target: aarch64-apple-darwin - default: true - - - name: Build aarch64-apple-darwin - run: cargo build --release --target=aarch64-apple-darwin - - - name: Set permissions for macOS binaries - run: | - chmod +x target/x86_64-apple-darwin/release/fta - chmod +x target/aarch64-apple-darwin/release/fta - - - name: Create tarballs - run: | - tar czvf x86_64-apple-darwin.tar.gz target/x86_64-apple-darwin/release/fta - tar czvf aarch64-apple-darwin.tar.gz target/aarch64-apple-darwin/release/fta + name: macos-binary - name: Upload macOS x86 tarball uses: actions/upload-release-asset@v1 @@ -94,42 +65,23 @@ jobs: asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-aarch64-apple-darwin.tar.gz asset_content_type: application/gzip + - name: Upload binaries as artifacts + uses: actions/upload-artifact@v2 + with: + name: macos-binaries + path: | + *.tar.gz + upload_assets_windows: needs: create_github_release runs-on: windows-latest steps: - uses: actions/checkout@v3 - - name: Setup Rust for x86_64-pc-windows-msvc - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - components: rustfmt, clippy - target: x86_64-pc-windows-msvc - default: true - override: true - - - name: Install 7zip - run: choco install 7zip - - - name: Build x86_64-pc-windows-msvc - run: cargo build --release --target=x86_64-pc-windows-msvc - - - name: Setup Rust for aarch64-pc-windows-msvc - uses: actions-rs/toolchain@v1 + - name: Download windows artifact + uses: actions/download-artifact@v2 with: - toolchain: stable - target: aarch64-pc-windows-msvc - default: true - override: true - - - name: Build aarch64-pc-windows-msvc - run: cargo build --release --target=aarch64-pc-windows-msvc - - - name: Create zipfiles - run: | - 7z a fta-x86_64-pc-windows-msvc.7z target/x86_64-pc-windows-msvc/release/fta.exe - 7z a fta-aarch64-pc-windows-msvc.7z target/aarch64-pc-windows-msvc/release/fta.exe + name: windows-binary - name: Upload Windows x86 zipfile uses: actions/upload-release-asset@v1 @@ -137,9 +89,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ needs.create_github_release.outputs.upload_url }} - asset_path: ./fta-x86_64-pc-windows-msvc.7z - asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-x86_64-pc-windows-msvc.7z - asset_content_type: application/x-7z-compressed + asset_path: ./x86_64-pc-windows-msvc.zip + asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-x86_64-pc-windows-msvc.zip + asset_content_type: application/zip - name: Upload Windows ARM64 zipfile uses: actions/upload-release-asset@v1 @@ -147,108 +99,121 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ needs.create_github_release.outputs.upload_url }} - asset_path: ./fta-aarch64-pc-windows-msvc.7z - asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-aarch64-pc-windows-msvc.7z - asset_content_type: application/x-7z-compressed + asset_path: ./aarch64-pc-windows-msvc.zip + asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-aarch64-pc-windows-msvc.zip + asset_content_type: application/zip + + - name: Upload binaries as artifacts + uses: actions/upload-artifact@v2 + with: + name: windows-binaries + path: | + *.zip upload_assets_linux: needs: create_github_release - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Update packages - run: sudo apt-get update - - - name: Install aarch64 dependencies - run: sudo apt-get install -y gcc-aarch64-linux-gnu libc6-dev-arm64-cross - - - name: Install ARM dependencies - run: sudo apt-get install -y gcc-arm-linux-gnueabihf libc6-dev-armhf-cross - - - name: Install aarch64-unknown-linux-musl dependencies - run: sudo apt-get install -y musl-tools - - - name: Install Rust - uses: actions-rs/toolchain@v1 + - name: Download linux artifact + uses: actions/download-artifact@v2 with: - toolchain: stable - components: rustfmt, clippy - profile: minimal - target: x86_64-unknown-linux-gnu + name: linux-binary - - name: Add Rust targets - run: | - rustup target add x86_64-unknown-linux-gnu - rustup target add aarch64-unknown-linux-gnu - rustup target add aarch64-unknown-linux-musl - rustup target add armv7-unknown-linux-gnueabihf - - - name: Install MUSL toolchain for AArch64 - run: | - wget -q https://musl.cc/aarch64-linux-musl-cross.tgz - tar -xf aarch64-linux-musl-cross.tgz - echo "$(pwd)/aarch64-linux-musl-cross/bin" >> $GITHUB_PATH - - - name: Build and tarball - run: | - TARGETS=( - x86_64-unknown-linux-gnu - aarch64-unknown-linux-gnu - aarch64-unknown-linux-musl - armv7-unknown-linux-gnueabihf - ) - - for TARGET in "${TARGETS[@]}"; do - echo "Building for $TARGET" - cargo build --release --target="$TARGET" - chmod +x target/${TARGET}/release/fta - tar czf "fta-${TARGET}.tar.gz" -C "./target/${TARGET}/release/" fta - done - - - name: Upload x86_64-unknown-linux-gnu tarball - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.create_github_release.outputs.upload_url }} - asset_path: ./fta-x86_64-unknown-linux-gnu.tar.gz - asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-x86_64-unknown-linux-gnu.tar.gz - asset_content_type: application/gzip - - - name: Upload aarch64-unknown-linux-gnu tarball + - name: Upload aarch64-unknown-linux-musl tarball uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ needs.create_github_release.outputs.upload_url }} - asset_path: ./fta-aarch64-unknown-linux-gnu.tar.gz - asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-aarch64-unknown-linux-gnu.tar.gz + asset_path: ./aarch64-unknown-linux-musl.tar.gz + asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-aarch64-unknown-linux-musl.tar.gz asset_content_type: application/gzip - - name: Upload aarch64-unknown-linux-musl tarball + - name: Upload x86_64-unknown-linux-musl tarball uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ needs.create_github_release.outputs.upload_url }} - asset_path: ./fta-aarch64-unknown-linux-musl.tar.gz - asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-aarch64-unknown-linux-musl.tar.gz + asset_path: ./x86_64-unknown-linux-musl.tar.gz + asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-x86_64-unknown-linux-musl.tar.gz asset_content_type: application/gzip - - name: Upload armv7-unknown-linux-gnueabihf tarball + - name: Upload arm-unknown-linux-musleabi tarball uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ needs.create_github_release.outputs.upload_url }} - asset_path: ./fta-armv7-unknown-linux-gnueabihf.tar.gz - asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-armv7-unknown-linux-gnueabihf.tar.gz + asset_path: ./arm-unknown-linux-musleabi.tar.gz + asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-arm-unknown-linux-musleabi.tar.gz asset_content_type: application/gzip + publish_rust_crate: + runs-on: ubuntu-latest + needs: [upload_assets_macos, upload_assets_windows, upload_assets_linux] + steps: - name: Publish to crates.io env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} run: | cargo publish --token $CARGO_REGISTRY_TOKEN working-directory: crates/fta + + publish_fta_cli: + needs: [upload_assets_macos, upload_assets_windows, upload_assets_linux] + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Node.js environment + uses: actions/setup-node@v3 + with: + node-version: 16 + + - name: Download macOS artifacts + uses: actions/download-artifact@v2 + with: + name: macos-binaries + path: artifact/ + + - name: Download linux artifacts + uses: actions/download-artifact@v2 + with: + name: linux-binaries + path: artifact/ + + - name: Download windows artifacts + uses: actions/download-artifact@v2 + with: + name: windows-binaries + path: artifact/ + + - name: Extract nix artifacts + run: | + for file in artifact/*.tar.gz; do + base=$(basename -- "$file") + dirname="${base%%.*}" + mkdir -p packages/fta/binaries/"$dirname" + tar -xzf "$file" -C packages/fta/binaries/"$dirname" + done + + - name: Extract artifacts + run: | + for file in artifact/*.zip; do + dir=$(basename "$file" .zip) + mkdir -p "packages/fta/binaries/$dir" + unzip -o "$file" -d "packages/fta/binaries/$dir" + done + + # List out the binaries dir + ls -R packages/fta/binaries/ + + - name: Publish to npm + run: npm publish + working-directory: packages/fta + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..797140e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,135 @@ +name: Test Rust package and built binaries + +on: + push: + branches: [main] + pull_request: + branches: ["*"] + +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: 0 + +jobs: + test_rust_crate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Basic build validation + run: | + cargo build + + - name: Check program + run: | + cargo check + + - name: Check formatting + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + - name: Run tests + uses: actions-rs/cargo@v1 + with: + command: test + args: --all-features + + - name: Output test coverage + run: | + cargo install cargo-tarpaulin + cargo tarpaulin --fail-under 75 + + build_binaries: + uses: ./.github/workflows/build.yml + + test_built_binaries: + needs: build_binaries + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + include: + - os: macos-latest + artifact: macos-binaries + - os: windows-latest + artifact: windows-binaries + - os: ubuntu-latest + artifact: linux-binaries + steps: + - uses: actions/checkout@v3 + + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: ${{ matrix.artifact }} + path: artifact/ + + - name: Extract artifact (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + $sourcePath = "artifact" + + # Get all .zip files from the sourcePath directory + $files = Get-ChildItem -Path $sourcePath -Recurse -Include "*.zip" + + # Loop through each .zip file + foreach ($file in $files) { + # Extract the file to the current directory + Expand-Archive -Path $file.FullName -DestinationPath "." -Force + } + + - name: Extract artifact (Linux/MacOS) + if: runner.os != 'Windows' + shell: bash + run: | + for file in artifact/*; do + tar -xf "$file" + done + + - name: Create sample folder and copy foo.ts + shell: bash + run: | + rm -rf sample + mkdir sample + cp ./.github/foo.ts sample/foo.ts + + - name: Test binary + shell: bash + run: | + EXPECTED_OUTPUT=$(cat <<'EOF' + [{"file_name":"foo.ts","cyclo":3,"halstead":{"uniq_operators":13,"uniq_operands":21,"total_operators":39,"total_operands":44,"program_length":34,"vocabulary_size":83,"volume":216.75134066579542,"difficulty":9.068181818181818,"effort":1965.5405664920995,"time":109.19669813844997,"bugs":0.07225044688859847},"line_count":23,"fta_score":42.65462143345264,"assessment":"OK"}] + EOF + ) + if [[ "${{ runner.os }}" == "Windows" ]]; then + OUTPUT=$(./fta.exe sample --json) + elif [[ "${{ runner.os }}" == "macOS" ]]; then + brew install jq + OUTPUT=$(./fta sample --json) + else + sudo apt-get install -y jq + OUTPUT=$(./fta sample --json) + fi + if [ "$(echo "$OUTPUT" | jq --sort-keys '.')" == "$(echo "$EXPECTED_OUTPUT" | jq --sort-keys '.')" ]; then + echo "Output matches expected" + else + echo "Output does not match expected." + echo "Expected:" + echo "$EXPECTED_OUTPUT" + echo "Got:" + echo "$OUTPUT" + exit 1 + fi + + publish_dry_run_nix: + needs: test_built_binaries + uses: ./.github/workflows/publish-dry-run.yml \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 8922061..33e510f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v0.2.0 + +- Potentially breaking: changed linux target platforms: we now target `musl` linux on `x86_64`, `arm` and `aarch64` + - This change should result in a more portable and widely compatible `fta-cli` on Linux systems +- Refactored Github Actions workflow so that the publishing of the npm packages is automatic and coupled with releasing the Rust crate + # v0.1.11 - Improved language detection, add retry mechanism ([#31](https://github.com/sgb-io/fta/pull/31)) diff --git a/Cargo.lock b/Cargo.lock index 216a88a..52aff93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,15 +24,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - [[package]] name = "aho-corasick" version = "1.0.2" @@ -101,7 +92,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.22", + "syn 2.0.26", ] [[package]] @@ -144,9 +135,9 @@ checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" [[package]] name = "bstr" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5" +checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" dependencies = [ "memchr", "serde", @@ -172,9 +163,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.3.10" +version = "4.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "384e169cc618c613d5e3ca6404dda77a8685a63e08660dcc64abaf7da7cb0c7a" +checksum = "5b0827b011f6f8ab38590295339817b0d26f344aa4932c3ced71b45b0c54b4a9" dependencies = [ "clap_builder", "clap_derive", @@ -183,9 +174,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.10" +version = "4.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef137bbe35aab78bdb468ccfba75a5f4d8321ae011d34063770780545176af2d" +checksum = "9441b403be87be858db6a23edb493e7f694761acdc3343d5a0fcaafd304cbc9e" dependencies = [ "anstream", "anstyle", @@ -195,14 +186,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.2" +version = "4.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.26", ] [[package]] @@ -327,12 +318,12 @@ dependencies = [ "pmutil", "proc-macro2", "swc_macros_common", - "syn 2.0.22", + "syn 2.0.26", ] [[package]] name = "fta" -version = "0.1.11" +version = "0.2.0" dependencies = [ "clap", "comfy-table", @@ -351,7 +342,7 @@ dependencies = [ [[package]] name = "fta-wasm" -version = "0.1.11" +version = "0.2.0" dependencies = [ "fta", "serde_json", @@ -371,11 +362,11 @@ dependencies = [ [[package]] name = "globset" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" +checksum = "1391ab1f92ffcc08911957149833e682aa3fe252b9f45f966d2ef972274c97df" dependencies = [ - "aho-corasick 0.7.20", + "aho-corasick", "bstr", "fnv", "log", @@ -399,9 +390,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "humantime" @@ -451,7 +442,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi 0.3.2", "libc", "windows-sys", ] @@ -466,25 +457,25 @@ dependencies = [ "pmutil", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.26", ] [[package]] name = "is-terminal" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24fddda5af7e54bf7da53067d6e802dbcc381d0a8eef629df528e3ebf68755cb" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.1", - "rustix 0.38.1", + "hermit-abi 0.3.2", + "rustix 0.38.4", "windows-sys", ] [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "lazy_static" @@ -722,7 +713,7 @@ checksum = "52a40bc70c2c58040d2d8b167ba9a5ff59fc9dab7ad44771cfde3dcfde7a09c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.26", ] [[package]] @@ -739,9 +730,9 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "proc-macro2" -version = "1.0.63" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] @@ -757,9 +748,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.29" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0" dependencies = [ "proc-macro2", ] @@ -805,20 +796,32 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.4" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" +checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" dependencies = [ - "aho-corasick 1.0.2", + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39354c10dd07468c2e73926b23bb9c2caca74c5501e38a35da70406f1d923310" +dependencies = [ + "aho-corasick", "memchr", "regex-syntax", ] [[package]] name = "regex-syntax" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" [[package]] name = "rustc-hash" @@ -828,9 +831,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.37.21" +version = "0.37.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25693a73057a1b4cb56179dd3c7ea21a7c6c5ee7d85781f5749b46f34b79c" +checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" dependencies = [ "bitflags 1.3.2", "errno", @@ -842,9 +845,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.1" +version = "0.38.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc6396159432b5c8490d4e301d8c705f61860b8b6c863bf79942ce5401968f3" +checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" dependencies = [ "bitflags 2.3.3", "errno", @@ -855,15 +858,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "same-file" @@ -882,35 +885,35 @@ checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.164" +version = "1.0.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" +checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.164" +version = "1.0.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" +checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.26", ] [[package]] name = "serde_json" -version = "1.0.99" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" +checksum = "d03b412469450d4404fe8499a268edd7f8b79fecb074b0d812ad64ca21f4031b" dependencies = [ "itoa", "ryu", @@ -919,9 +922,9 @@ dependencies = [ [[package]] name = "signal-hook" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "732768f1176d21d09e076c23a93123d40bba92d50c4058da34d45c8de8e682b9" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" dependencies = [ "libc", "signal-hook-registry", @@ -955,9 +958,9 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "smartstring" @@ -1031,7 +1034,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.22", + "syn 2.0.26", ] [[package]] @@ -1061,9 +1064,9 @@ dependencies = [ [[package]] name = "swc_atoms" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93d0307dc4bfd107d49c7528350c372758cfca94fb503629b9a056e6a1572860" +checksum = "3b1370fa1d31e18a999928aaf18f166616b16c5cb7033ced7d50d06858c5fd90" dependencies = [ "once_cell", "rustc-hash", @@ -1075,9 +1078,9 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.31.16" +version = "0.31.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6414bd4e553f5638961d39b07075ffd37a3d63176829592f4a5900260d94ca1" +checksum = "e1362dec11e2270048e686f0c7d4a9087fcf1ec9d27147c2c226929a806a86f6" dependencies = [ "ahash", "ast_node", @@ -1159,7 +1162,7 @@ dependencies = [ "pmutil", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.26", ] [[package]] @@ -1171,7 +1174,7 @@ dependencies = [ "pmutil", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.26", ] [[package]] @@ -1195,7 +1198,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.22", + "syn 2.0.26", ] [[package]] @@ -1211,9 +1214,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.22" +version = "2.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2efbeae7acf4eabd6bcdcbd11c92f45231ddda7539edc7806bd1a04a03b24616" +checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970" dependencies = [ "proc-macro2", "quote", @@ -1230,7 +1233,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall", - "rustix 0.37.21", + "rustix 0.37.23", "windows-sys", ] @@ -1288,7 +1291,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.26", ] [[package]] @@ -1302,9 +1305,9 @@ dependencies = [ [[package]] name = "triomphe" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1ee9bd9239c339d714d657fac840c6d2a4f9c45f4f9ec7b0975113458be78db" +checksum = "0eee8098afad3fb0c54a9007aab6804558410503ad676d4633f9c2559a00ac0f" dependencies = [ "serde", "stable_deref_trait", @@ -1330,9 +1333,9 @@ checksum = "d70b6494226b36008c8366c288d77190b3fad2eb4c10533139c1c1f461127f1a" [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-normalization" @@ -1409,7 +1412,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.26", "wasm-bindgen-shared", ] @@ -1431,7 +1434,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.26", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/MAINTENANCE.md b/MAINTENANCE.md index 0309baf..52e735c 100644 --- a/MAINTENANCE.md +++ b/MAINTENANCE.md @@ -11,31 +11,24 @@ The NPM `fta-cli` package is a super thin layer that simply calls the relevant ` ## Development -Use PRs into `main`. GitHub actions are set up to test and verify changes to the Rust crate, but nothing is in place for the NPM package. +Use PRs into `main`. GitHub Actions are set up to: -The NPM package is plain JavaScript with no tests or build step, since those things aren't really warranted. +- Compile the Rust crate & run Rust tests, output test coverage (Ubuntu) +- Build binaries for all targets on windows/macos/linux +- Smoke test all built binaries against a sample file +- Construct the NPM package, i.e. install the compiled binaries into `packages/fta/binaries` +- Publish the NPM package locally using Verdaccio +- Smoke test the verdaccio-published NPM package via a sample file -## Publishing and releasing (`fta` crate, `fta-cli` npm package) - -The Rust crate should always be published first, then the NPM package. - -The two packages should use the same version number (but the Rust crate is still published / in existence first). - -The Rust crate is published **automatically by GitHub actions**, but the NPM package is published manually (locally). - -1. Merge work into `main` over time -2. When you want to release, manually bump the version in `crates/fta/Cargo.toml`, run `cargo update` so that the lockfile updates too. Do this in a PR and merge it to main. -3. Manually update `CHANGELOG.md` -4. When you're satisfied everything is ready on `main` (and the build is green), locally tag the repo with a new version e.g. `v1.0.0`. Push this tag to trigger the Rust crate release process. -5. If you want any changes to the NPM package itself as part of this new version, also make those changes. This can be merged to main after the Crate release has happened. -6. Assuming the Rust crate release was successful (step 3), there should be a draft GitHub release, containing the new binaries. Publish the release and download all the binaries. -7. Place the binaries in the relevant directories in `packages/fta/bin` (they should be .gitignore'd). Optionally run `npm run prepublishOnly` from the NPM package directory to verify that all binaries are installed. -8. Bump the NPM package version if you didn't already. This can be pushed to main whenever, but it needs to happen before manually publishing to NPM. -9. Manually publish the NPM package. You can optionally run `npm pack` and/or the `--dry-run` option to double check what will be published. You can also use `npm pack` to test the package out locally. +The NPM CLI package itself is plain JavaScript without any Node.js tests or build step, since those things aren't really warranted. -Note: the NPM package has a `prepublishOnly` script that should automatically run ahead of publishing - this verifies that all binaries are installed. +## Publishing and releasing (`fta` crate, `fta-cli` npm package) -Although the versions of the two packages are not functionally linked, it's a good idea to keep them in sync to keep things simple. If a mistake is made with the npm package, a patch bump to the Rust crate is a better fix than inconsistent versions or attempting to unpublish. +1. Merge changes over time to `main`, with green builds to verify everything is healthy +2. Bump versions and update `CHANGELOG.md` + 1. Set the version in `packages/fta/package.json` + 2. Set the version in `crates/fta/Cargo.toml`, run `cargo update` so that the lockfile updates too. Do this in a PR and merge it to `main`. +3. When you're satisfied everything is ready on `main` (and the build is green), locally tag the repo with a new version e.g. `v1.0.0`. Push this tag to trigger the release. ## WASM npm package @@ -47,15 +40,11 @@ This should be published manually. From the `crates/fta-wasm` directory: 4. If you want to locally debug before publish, you can paste the contents of `pkg` to override an existing version in `node_modules.` 5. Run `wasm-pack publish pkg`. This directly publishes the output to NPM. -## Why not more automatic? - -It's complex: the NPM package relies on the Rust crate binaries, which currently only get built in CI & uploaded to the GitHub release. - -A potential improvement on this publishing workflow is to keep hold of the binaries in CI and use them as input to an NPM package publish job. The NPM package version would also need bumping in this scenario. - ## Code Coverage -Install and run `tarpaulin`: +Code coverage is reported during the `test` workflow. + +To check the coverage locally, install and run `tarpaulin`: ``` cargo install cargo-tarpaulin diff --git a/crates/fta-wasm/Cargo.toml b/crates/fta-wasm/Cargo.toml index 0d7bb8f..4c657e3 100644 --- a/crates/fta-wasm/Cargo.toml +++ b/crates/fta-wasm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fta-wasm" -version = "0.1.11" +version = "0.2.0" edition = "2021" license = "MIT OR Apache-2.0" description = "Fast TypeScript Analyzer" diff --git a/crates/fta/Cargo.toml b/crates/fta/Cargo.toml index c275565..f3ebb92 100644 --- a/crates/fta/Cargo.toml +++ b/crates/fta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fta" -version = "0.1.11" +version = "0.2.0" edition = "2021" license = "MIT OR Apache-2.0" description = "Fast TypeScript Analyzer" @@ -9,8 +9,6 @@ documentation = "https://github.com/sgb-io/fta" repository = "https://github.com/sgb-io/fta" readme = "../../README.md" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] clap = { version = "4.2.7", features = ["derive"] } comfy-table = "7.0.0" diff --git a/packages/fta/.gitignore b/packages/fta/.gitignore index 5e210f0..95a0750 100644 --- a/packages/fta/.gitignore +++ b/packages/fta/.gitignore @@ -1,9 +1,3 @@ node_modules -binaries/aarch64-pc-windows-msvc/fta.exe -binaries/x86_64-pc-windows-msvc/fta.exe -binaries/aarch64-unknown-linux-gnu/fta -binaries/aarch64-unknown-linux-musl/fta -binaries/armv7-unknown-linux-gnueabihf/fta -binaries/x86_64-apple-darwin/fta -binaries/aarch64-apple-darwin/fta -binaries/x86_64-unknown-linux-gnu/fta +binaries/**/fta.exe +binaries/**/fta diff --git a/packages/fta/README.md b/packages/fta/README.md index a03c31a..f03e08e 100644 --- a/packages/fta/README.md +++ b/packages/fta/README.md @@ -25,31 +25,51 @@ npx fta-cli path/to/project Example output against the Redux project: ``` -| ----------------------------------------- | ------------ | ----------------------------- | ------------------- | -| File | Num. lines | FTA Score (Lower is better) | Assessment | -| ----------------------------------------- | ------------ | ----------------------------- | ------------------- | -| src\createStore.ts | 490 | 70.25 | (Needs improvement) | -| website\src\pages\index.js | 218 | 64.94 | (Needs improvement) | -| src\combineReducers.ts | 202 | 61.61 | (Needs improvement) | -| src\compose.ts | 62 | 52.68 | (Could be better) | -| src\bindActionCreators.ts | 84 | 51.89 | (Could be better) | -| src\utils\kindOf.ts | 71 | 48.80 | OK | -| src\utils\warning.ts | 19 | 35.00 | OK | -| src\utils\isPlainObject.ts | 15 | 34.32 | OK | -| src\utils\symbol-observable.ts | 11 | 31.89 | OK | -| website\docusaurus.config.js | 197 | 18.04 | OK | -| website\sidebars.js | 149 | 15.82 | OK | -| rollup.config.js | 80 | 15.79 | OK | -| tsup.config.ts | 73 | 15.59 | OK | -| src\applyMiddleware.ts | 78 | 15.45 | OK | -| website\src\pages\errors.js | 63 | 15.09 | OK | -| website\src\js\monokaiTheme.js | 63 | 14.32 | OK | -| src\utils\actionTypes.ts | 18 | 11.91 | OK | -| src\index.ts | 47 | 11.84 | OK | -| vitest.config.ts | 18 | 9.92 | OK | -| docs\components\DetailedExplanation.jsx | 16 | 9.67 | OK | -| src\utils\formatProdErrorMessage.ts | 14 | 8.57 | OK | -| ----------------------------------------- | ------------ | ----------------------------- | ------------------- | +┌─────────────────────────────────────────┬────────────┬─────────────────────────────┬───────────────────┐ +│ File ┆ Num. lines ┆ FTA Score (Lower is better) ┆ Assessment │ +╞═════════════════════════════════════════╪════════════╪═════════════════════════════╪═══════════════════╡ +│ src\createStore.ts ┆ 489 ┆ 70.34 ┆ Needs improvement │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ website\src\pages\index.js ┆ 217 ┆ 64.65 ┆ Needs improvement │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ src\combineReducers.ts ┆ 201 ┆ 61.56 ┆ Needs improvement │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ src\compose.ts ┆ 61 ┆ 52.52 ┆ Could be better │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ src\bindActionCreators.ts ┆ 83 ┆ 51.78 ┆ Could be better │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ src\utils\kindOf.ts ┆ 70 ┆ 48.66 ┆ OK │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ src\utils\warning.ts ┆ 18 ┆ 34.49 ┆ OK │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ src\utils\isPlainObject.ts ┆ 14 ┆ 33.66 ┆ OK │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ src\utils\symbol-observable.ts ┆ 10 ┆ 30.99 ┆ OK │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ website\docusaurus.config.js ┆ 196 ┆ 18.04 ┆ OK │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ website\sidebars.js ┆ 148 ┆ 15.82 ┆ OK │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ rollup.config.js ┆ 79 ┆ 15.79 ┆ OK │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ tsup.config.ts ┆ 72 ┆ 15.59 ┆ OK │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ src\applyMiddleware.ts ┆ 77 ┆ 15.45 ┆ OK │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ website\src\pages\errors.js ┆ 62 ┆ 15.07 ┆ OK │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ website\src\js\monokaiTheme.js ┆ 62 ┆ 14.32 ┆ OK │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ src\utils\actionTypes.ts ┆ 17 ┆ 11.91 ┆ OK │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ src\index.ts ┆ 46 ┆ 11.84 ┆ OK │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ vitest.config.ts ┆ 17 ┆ 9.92 ┆ OK │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ docs\components\DetailedExplanation.jsx ┆ 15 ┆ 9.53 ┆ OK │ +├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ +│ src\utils\formatProdErrorMessage.ts ┆ 13 ┆ 8.57 ┆ OK │ +└─────────────────────────────────────────┴────────────┴─────────────────────────────┴───────────────────┘ 21 files analyzed in 0.1079s. ``` diff --git a/packages/fta/index.js b/packages/fta/index.js index de8e75a..bf7fcba 100644 --- a/packages/fta/index.js +++ b/packages/fta/index.js @@ -25,15 +25,11 @@ function getBinaryPath() { } case "linux": if (architecture === "x64") { - return path.join(targetDirectory, "x86_64-unknown-linux-gnu", "fta"); + return path.join(targetDirectory, "x86_64-unknown-linux-musl", "fta"); } else if (architecture === "arm64") { - return path.join(targetDirectory, "aarch64-unknown-linux-gnu", "fta"); + return path.join(targetDirectory, "aarch64-unknown-linux-musl", "fta"); } else if (architecture === "arm") { - return path.join( - targetDirectory, - "armv7-unknown-linux-gnueabihf", - "fta" - ); + return path.join(targetDirectory, "arm-unknown-linux-musleabi", "fta"); } break; default: diff --git a/packages/fta/package.json b/packages/fta/package.json index dc6f0d9..09376f4 100644 --- a/packages/fta/package.json +++ b/packages/fta/package.json @@ -1,6 +1,6 @@ { "name": "fta-cli", - "version": "0.1.11", + "version": "0.2.0", "description": "FTA (Fast TypeScript Analyzer) is a super-fast TypeScript static analysis tool written in Rust", "repository": "https://github.com/sgb-io/fta.git", "author": "sgb-io ", diff --git a/packages/fta/targets.js b/packages/fta/targets.js index b85c840..fe9564f 100644 --- a/packages/fta/targets.js +++ b/packages/fta/targets.js @@ -1,12 +1,14 @@ +// Windows const exeTargets = ["aarch64-pc-windows-msvc", "x86_64-pc-windows-msvc"]; const plainTargets = [ - "aarch64-unknown-linux-gnu", - // "aarch64-unknown-linux-musl", // Not usually needed - "armv7-unknown-linux-gnueabihf", + // macOS "x86_64-apple-darwin", "aarch64-apple-darwin", - "x86_64-unknown-linux-gnu", + // Linux + "x86_64-unknown-linux-musl", + "aarch64-unknown-linux-musl", + "arm-unknown-linux-musleabi", ]; module.exports.exeTargets = exeTargets;