diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b815952..0d62941 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -123,89 +123,77 @@ jobs: name: artifact-bin-windows-${{ matrix.arch }} path: supa-mdx-lint-Windows-${{ matrix.arch }}.exe if-no-files-found: "error" -# node: -# name: NPM Package -# runs-on: ubuntu-latest -# needs: [linux, macos, macos_universal, windows] -# -# steps: -# - uses: actions/checkout@v2 -# -# - uses: actions/setup-node@v1 -# with: -# node-version: "20.10.0" -# -# - name: Download compiled binaries -# uses: actions/download-artifact@v4 -# with: -# pattern: artifact-bin-* -# merge-multiple: true -# -# - name: Calculate and store checksums -# shell: bash -# run: | -# sha256sum sentry-cli-* | awk '{printf("%s=%s\n", $2, $1)}' > checksums.txt -# cat checksums.txt -# -# - run: npm pack -# -# - uses: actions/upload-artifact@v4 -# with: -# name: artifact-pkg-node -# path: "*.tgz" -# if-no-files-found: "error" -# -# npm-distributions: -# name: "Build NPM distributions" -# runs-on: ubuntu-latest -# needs: [linux, macos, macos_universal, windows] -# steps: -# - uses: actions/checkout@v3 -# - uses: actions/setup-node@v4 -# with: -# node-version: "20.10.0" -# - uses: actions/download-artifact@v4 -# with: -# pattern: artifact-bin-* -# merge-multiple: true -# path: binary-artifacts -# - name: Move binaries into distribution packages -# run: | -# mv binary-artifacts/sentry-cli-Darwin-universal npm-binary-distributions/darwin/bin/sentry-cli -# mv binary-artifacts/sentry-cli-Linux-armv7 npm-binary-distributions/linux-arm/bin/sentry-cli -# mv binary-artifacts/sentry-cli-Linux-aarch64 npm-binary-distributions/linux-arm64/bin/sentry-cli -# mv binary-artifacts/sentry-cli-Linux-i686 npm-binary-distributions/linux-i686/bin/sentry-cli -# mv binary-artifacts/sentry-cli-Linux-x86_64 npm-binary-distributions/linux-x64/bin/sentry-cli -# mv binary-artifacts/sentry-cli-Windows-i686.exe npm-binary-distributions/win32-i686/bin/sentry-cli.exe -# mv binary-artifacts/sentry-cli-Windows-x86_64.exe npm-binary-distributions/win32-x64/bin/sentry-cli.exe -# - name: Remove binary placeholders -# run: rm -rf npm-binary-distributions/*/bin/.gitkeep -# - name: Make Linux binaries executable -# run: chmod +x npm-binary-distributions/*/bin/sentry-cli -# - name: Package distribution packages -# run: | -# for dir in npm-binary-distributions/*; do -# cd $dir -# npm pack -# cd - -# done -# -# - name: Upload packaged npm binary distributions -# uses: actions/upload-artifact@v4 -# with: -# name: artifact-npm-binary-distributions -# path: npm-binary-distributions/*/*.tgz -# if-no-files-found: "error" -# -# merge: -# name: Create Release Artifact -# runs-on: ubuntu-latest -# needs: -# [linux, macos, macos_universal, windows, npm-distributions, node, python] -# steps: -# - uses: actions/upload-artifact/merge@v4 -# with: -# # Craft expects release assets to be a single artifact named after the sha. -# name: ${{ github.sha }} -# pattern: artifact-* -# delete-merged: true + + node: + name: NPM Package + runs-on: ubuntu-latest + needs: [linux, macos, macos_universal, windows] + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + with: + node-version: "20.10.0" + + - name: Download compiled binaries + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + pattern: artifact-bin-* + merge-multiple: true + + - name: Calculate and store checksums + shell: bash + run: | + sha256sum supa-mdx-lint-* | awk '{printf("%s=%s\n", $2, $1)}' > checksums.txt + cat checksums.txt + + - run: npm pack + working-directory: packages/supa-mdx-lint + + - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 #v4.4.3 + with: + name: artifact-pkg-node + path: "packages/supa-mdx-lint/*.tgz" + if-no-files-found: "error" + + npm-distributions: + name: "Build NPM distributions" + runs-on: ubuntu-latest + needs: [linux, macos, macos_universal, windows] + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + with: + node-version: "20.10.0" + - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + pattern: artifact-bin-* + merge-multiple: true + path: binary-artifacts + - name: Move binaries into distribution packages + run: | + mv binary-artifacts/supa-mdx-lint-Darwin-universal npm-binary-distributions/darwin/bin/supa-mdx-lint + mv binary-artifacts/supa-mdx-lint-Linux-armv7 npm-binary-distributions/linux-arm/bin/supa-mdx-lint + mv binary-artifacts/supa-mdx-lint-Linux-aarch64 npm-binary-distributions/linux-arm64/bin/supa-mdx-lint + mv binary-artifacts/supa-mdx-lint-Linux-i686 npm-binary-distributions/linux-i686/bin/supa-mdx-lint + mv binary-artifacts/supa-mdx-lint-Linux-x86_64 npm-binary-distributions/linux-x64/bin/supa-mdx-lint + mv binary-artifacts/supa-mdx-lint-Windows-i686.exe npm-binary-distributions/win32-i686/bin/supa-mdx-lint.exe + mv binary-artifacts/supa-mdx-lint-Windows-x86_64.exe npm-binary-distributions/win32-x64/bin/supa-mdx-lint.exe + - name: Remove binary placeholders + run: rm -rf npm-binary-distributions/*/bin/.gitkeep + - name: Make binaries executable + run: chmod +x npm-binary-distributions/*/bin/supa-mdx-lint + - name: Package distribution packages + run: | + for dir in npm-binary-distributions/*; do + cd $dir + npm pack + cd - + done + + - name: Upload packaged npm binary distributions + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 #v4.4.3 + with: + name: artifact-npm-binary-distributions + path: npm-binary-distributions/*/*.tgz + if-no-files-found: "error" diff --git a/Cargo.lock b/Cargo.lock index ec9bee9..97f8a39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.15" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -28,43 +28,43 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.4" +version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" [[package]] name = "assert_cmd" @@ -96,9 +96,9 @@ checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bstr" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" +checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22" dependencies = [ "memchr", "regex-automata", @@ -113,9 +113,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.20" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" dependencies = [ "clap_builder", "clap_derive", @@ -123,9 +123,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.20" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" dependencies = [ "anstream", "anstyle", @@ -147,15 +147,15 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "colorchoice" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "crop" @@ -169,9 +169,9 @@ dependencies = [ [[package]] name = "ctor" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" +checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501" dependencies = [ "quote", "syn", @@ -235,12 +235,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -251,9 +251,9 @@ checksum = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193" [[package]] name = "fastrand" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "float-cmp" @@ -290,9 +290,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "indexmap" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", "hashbrown", @@ -315,15 +315,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" [[package]] name = "linux-raw-sys" @@ -426,9 +426,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -444,9 +444,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -456,9 +456,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -473,9 +473,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustix" -version = "0.38.37" +version = "0.38.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" dependencies = [ "bitflags", "errno", @@ -492,18 +492,18 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", @@ -512,9 +512,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", "memchr", @@ -569,7 +569,7 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "supa-mdx-lint" -version = "0.1.0" +version = "0.1.6-pre" dependencies = [ "anyhow", "assert_cmd", @@ -604,9 +604,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.87" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -615,9 +615,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", "fastrand", @@ -643,18 +643,18 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "2.0.3" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +checksum = "2f49a1853cf82743e3b7950f77e0f4d622ca36cf4317cba00c767838bac8d490" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.3" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061" dependencies = [ "proc-macro2", "quote", @@ -663,9 +663,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.36" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" dependencies = [ "deranged", "itoa", @@ -686,9 +686,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" dependencies = [ "num-conv", "time-core", @@ -736,9 +736,9 @@ checksum = "10103c57044730945224467c09f71a4db0071c123a0648cc3e818913bde6b561" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-segmentation" diff --git a/Cargo.toml b/Cargo.toml index 2e8b39b..6ec25d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "supa-mdx-lint" description = "Lint MDX files according to the Supabase style guide" author = "Charis Lam" -version = "0.1.0" +version = "0.1.6-pre" edition = "2021" [dependencies] diff --git a/npm-binary-distributions/darwin/bin/.gitkeep b/npm-binary-distributions/darwin/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/npm-binary-distributions/darwin/package.json b/npm-binary-distributions/darwin/package.json new file mode 100644 index 0000000..ba0c926 --- /dev/null +++ b/npm-binary-distributions/darwin/package.json @@ -0,0 +1,10 @@ +{ + "name": "@supabase/supa-mdx-lint-darwin", + "version": "0.1.6-pre", + "engines": { + "node": ">=10" + }, + "os": [ + "darwin" + ] +} diff --git a/npm-binary-distributions/linux-arm/bin/.gitkeep b/npm-binary-distributions/linux-arm/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/npm-binary-distributions/linux-arm/package.json b/npm-binary-distributions/linux-arm/package.json new file mode 100644 index 0000000..13db9bd --- /dev/null +++ b/npm-binary-distributions/linux-arm/package.json @@ -0,0 +1,14 @@ +{ + "name": "@supabase/supa-mdx-lint-linux-arm", + "version": "0.1.6-pre", + "engines": { + "node": ">=10" + }, + "os": [ + "linux", + "freebsd" + ], + "cpu": [ + "arm" + ] +} diff --git a/npm-binary-distributions/linux-arm64/bin/.gitkeep b/npm-binary-distributions/linux-arm64/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/npm-binary-distributions/linux-arm64/package.json b/npm-binary-distributions/linux-arm64/package.json new file mode 100644 index 0000000..92a3aae --- /dev/null +++ b/npm-binary-distributions/linux-arm64/package.json @@ -0,0 +1,14 @@ +{ + "name": "@supabase/supa-mdx-lint-linux-arm64", + "version": "0.1.6-pre", + "engines": { + "node": ">=10" + }, + "os": [ + "linux", + "freebsd" + ], + "cpu": [ + "arm64" + ] +} diff --git a/npm-binary-distributions/linux-i686/bin/.gitkeep b/npm-binary-distributions/linux-i686/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/npm-binary-distributions/linux-i686/package.json b/npm-binary-distributions/linux-i686/package.json new file mode 100644 index 0000000..cdd5cbc --- /dev/null +++ b/npm-binary-distributions/linux-i686/package.json @@ -0,0 +1,15 @@ +{ + "name": "@supabase/supa-mdx-lint-linux-i686", + "version": "0.1.6-pre", + "engines": { + "node": ">=10" + }, + "os": [ + "linux", + "freebsd" + ], + "cpu": [ + "x86", + "ia32" + ] +} diff --git a/npm-binary-distributions/linux-x64/bin/.gitkeep b/npm-binary-distributions/linux-x64/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/npm-binary-distributions/linux-x64/package.json b/npm-binary-distributions/linux-x64/package.json new file mode 100644 index 0000000..b35079b --- /dev/null +++ b/npm-binary-distributions/linux-x64/package.json @@ -0,0 +1,14 @@ +{ + "name": "@supabase/supa-mdx-lint-linux-x64", + "version": "0.1.6-pre", + "engines": { + "node": ">=10" + }, + "os": [ + "linux", + "freebsd" + ], + "cpu": [ + "x64" + ] +} diff --git a/npm-binary-distributions/win32-i686/bin/.gitkeep b/npm-binary-distributions/win32-i686/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/npm-binary-distributions/win32-i686/package.json b/npm-binary-distributions/win32-i686/package.json new file mode 100644 index 0000000..45564e9 --- /dev/null +++ b/npm-binary-distributions/win32-i686/package.json @@ -0,0 +1,14 @@ +{ + "name": "@supabase/supa-mdx-lint-win32-i686", + "version": "0.1.6-pre", + "engines": { + "node": ">=10" + }, + "os": [ + "win32" + ], + "cpu": [ + "x86", + "ia32" + ] +} diff --git a/npm-binary-distributions/win32-x64/bin/.gitkeep b/npm-binary-distributions/win32-x64/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/npm-binary-distributions/win32-x64/package.json b/npm-binary-distributions/win32-x64/package.json new file mode 100644 index 0000000..8bdf718 --- /dev/null +++ b/npm-binary-distributions/win32-x64/package.json @@ -0,0 +1,13 @@ +{ + "name": "@supabase/supa-mdx-lint-win32-x64", + "version": "0.1.6-pre", + "engines": { + "node": ">=10" + }, + "os": [ + "win32" + ], + "cpu": [ + "x64" + ] +} diff --git a/packages/supa-mdx-lint/package.json b/packages/supa-mdx-lint/package.json index ed0db78..836ca4d 100644 --- a/packages/supa-mdx-lint/package.json +++ b/packages/supa-mdx-lint/package.json @@ -1,29 +1,26 @@ { - "name": "supa-mdx-lint", - "version": "0.1.0", - "type": "module", - "main": "dist/index.js", + "name": "@supabase/supa-mdx-lint", + "version": "0.1.6-pre", + "main": "src/index.js", "scripts": { - "build": "tsc", "format": "prettier --write .", "format:check": "prettier --check .", "lint": "eslint .", "test": "vitest" }, - "files": [ - "dist", - "pkg", - "src/index.ts" - ], "devDependencies": { "@supa-mdx-lint/eslint-config": "*", "@types/node": "^22.7.5", "eslint": "^9.13.0", - "prettier": "^3.3.3", - "typescript": "^5.6.3", - "vitest": "^2.1.2" + "prettier": "^3.3.3" }, - "dependencies": { - "toml": "^3.0.0" + "optionalDependencies": { + "@supabase/supa-mdx-lint-darwin": "0.1.6-pre", + "@supabase/supa-mdx-lint-linux-arm": "0.1.6-pre", + "@supabase/supa-mdx-lint-linux-arm64": "0.1.6-pre", + "@supabase/supa-mdx-lint-linux-i686": "0.1.6-pre", + "@supabase/supa-mdx-lint-linux-x64": "0.1.6-pre", + "@supabase/supa-mdx-lint-win32-i686": "0.1.6-pre", + "@supabase/supa-mdx-lint-win32-x64": "0.1.6-pre" } } diff --git a/packages/supa-mdx-lint/src/helper.js b/packages/supa-mdx-lint/src/helper.js new file mode 100644 index 0000000..06f0993 --- /dev/null +++ b/packages/supa-mdx-lint/src/helper.js @@ -0,0 +1,191 @@ +/** + * Adapted from https://github.com/getsentry/sentry-cli + * Under the [BSD 3-Clause License](https://github.com/getsentry/sentry-cli/blob/master/LICENSE) + */ + +// @ts-check + +"use strict"; + +const childProcess = require("child_process"); +const os = require("os"); + +const BINARY_DISTRIBUTIONS = [ + { + packageName: "@supabase/supa-mdx-lint-darwin", + subpath: "bin/supa-mdx-lint", + }, + { + packageName: "@supabase/supa-mdx-lint-linux-x64", + subpath: "bin/supa-mdx-lint", + }, + { + packageName: "@supabase/supa-mdx-lint-linux-i686", + subpath: "bin/supa-mdx-lint", + }, + { + packageName: "@supabse/supa-mdx-lint-linux-arm64", + subpath: "bin/supa-mdx-lint", + }, + { + packageName: "@supabase/supa-mdx-lint-linux-arm", + subpath: "bin/supa-mdx-lint", + }, + { + packageName: "@supabase/supa-mdx-lint-win32-x64", + subpath: "bin/supa-mdx-lint.exe", + }, + { packageName: "@supabase/cli-win32-i686", subpath: "bin/supa-mdx-lint.exe" }, +]; + +function getDistributionForThisPlatform() { + const arch = os.arch(); + const platform = os.platform(); + + let packageName = undefined; + if (platform === "darwin") { + packageName = "@supabase/supa-mdx-lint-darwin"; + } else if (platform === "linux" || platform === "freebsd") { + switch (arch) { + case "x64": + packageName = "@supabase/supa-mdx-lint-linux-x64"; + break; + case "x86": + case "ia32": + packageName = "@supabase/supa-mdx-lint-linux-i686"; + break; + case "arm64": + packageName = "@supabase/supa-mdx-lint-linux-arm64"; + break; + case "arm": + packageName = "@supabase/supa-mdx-lint-linux-arm"; + break; + } + } else if (platform === "win32") { + switch (arch) { + case "x64": + // Windows arm64 can run x64 binaries + // @eslint-disable-next-line no-fallthrough + case "arm64": + packageName = "@supabase/supa-mdx-lint-win32-x64"; + break; + case "x86": + case "ia32": + packageName = "@supabase/supa-mdx-lint-win32-i686"; + break; + } + } + + let subpath = undefined; + switch (platform) { + case "win32": + subpath = "bin/supa-mdx-lint.exe"; + break; + case "darwin": + case "linux": + case "freebsd": + subpath = "bin/supa-mdx-lint"; + break; + default: + subpath = "bin/supa-mdx-lint"; + break; + } + + return { packageName, subpath }; +} + +/** + * Throws an error with a message stating that supa-mdx-lint doesn't support the current platform. + * + * @returns {never} nothing. It throws. + */ +function throwUnsupportedPlatformError() { + throw new Error( + `Unsupported operating system or architecture! supa-mdx-lint does not work on this architecture. + +supa-mdx-lint supports: +- Darwin (macOS) +- Linux and FreeBSD on x64, x86, ia32, arm64, and arm architectures +- Windows x64, x86, and ia32 architectures`, + ); +} + +/** + * Tries to find the installed supa-mdx-lint binary - either by looking into the relevant + * optional dependencies or by trying to resolve the fallback binary. + * + * @returns {string} The path to the supa-mdx-lint binary + */ +function getBinaryPath() { + if (process.env.SUPA_MDX_LINT_BINARY_PATH) { + return process.env.SUPA_MDX_LINT_BINARY_PATH; + } + + const { packageName, subpath } = getDistributionForThisPlatform(); + + if (packageName === undefined) { + throwUnsupportedPlatformError(); + } + + let compatibleBinaryPath; + try { + compatibleBinaryPath = require.resolve(`${packageName}/${subpath}`); + } catch { + const otherInstalledDistribution = BINARY_DISTRIBUTIONS.find( + ({ packageName, subpath }) => { + try { + require.resolve(`${packageName}/${subpath}`); + return true; + } catch { + return false; + } + }, + ); + + // These error messages are heavily inspired by esbuild's error messages: https://github.com/evanw/esbuild/blob/f3d535262e3998d845d0f102b944ecd5a9efda57/lib/npm/node-platform.ts#L150 + if (otherInstalledDistribution) { + throw new Error(`supa-mdx-lint binary for this platform/architecture not found! + +The "${otherInstalledDistribution.packageName}" package is installed, but for the current platform, you should have the "${packageName}" package installed instead. This usually happens if the "supa-mdx-lint" package is installed on one platform (for example Windows or MacOS) and then the "node_modules" folder is reused on another operating system (for example Linux in Docker). + +To fix this, avoid copying the "node_modules" folder, and instead freshly install your dependencies on the target system. You can also configure your package manager to install the right package. For example, yarn has the "supportedArchitectures" feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitecture.`); + } else { + throw new Error(`supa-mdx-lint binary for this platform/architecture not found! + +It seems like none of the "@supabase/supa-mdx-lint" package's optional dependencies got installed. Please make sure your package manager is configured to install optional dependencies. If you are using npm to install your dependencies, please don't set the "--no-optional", "--ignore-optional", or "--omit=optional" flags. supa-mdx-lint needs the "optionalDependencies" feature in order to install its binary.`); + } + } + + return compatibleBinaryPath; +} + +/** + * Runs `supa-mdx-lint` with the given command line arguments. + * + * @example + * const output = await execute(['--version']); + * expect(output.trim()).toBe('supa-mdx-lint x.y.z'); + * + * @param {string[]} args Command line arguments passed to `supa-mdx-lint`. + * @returns {Promise} A promise that resolves to the standard output. + */ +async function execute(args) { + const env = { ...process.env }; + return new Promise((resolve, reject) => { + const pid = childProcess.spawn(getBinaryPath(), args, { + env, + // stdin, stdout, stderr + stdio: ["ignore", "inherit", "inherit"], + }); + pid.on("error", (err) => { + reject(err); + }); + pid.on("exit", () => { + resolve(); + }); + }); +} + +module.exports = { + execute, +}; diff --git a/packages/supa-mdx-lint/src/index.js b/packages/supa-mdx-lint/src/index.js new file mode 100644 index 0000000..cfe630a --- /dev/null +++ b/packages/supa-mdx-lint/src/index.js @@ -0,0 +1,19 @@ +//@ ts-check + +"use strict"; + +const helper = require("./helper"); + +async function main() { + const args = process.argv.slice(2); + await helper.execute(args); +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); + +if (require.main === module) { + main(); +} diff --git a/packages/supa-mdx-lint/src/index.ts b/packages/supa-mdx-lint/src/index.ts deleted file mode 100644 index a3a95d5..0000000 --- a/packages/supa-mdx-lint/src/index.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { readFile } from "node:fs/promises"; - -import * as wasm from "../pkg/supa_mdx_lint.js"; -import { join } from "node:path"; - -export type LintTarget = wasm.JsLintTarget & { - _type: "fileOrDirectory" | "string"; -}; -export type LintError = wasm.JsLintError; - -const CONFIGURATION_FILE = "supa-mdx-lint.json"; - -export class Linter { - private linter: wasm.Linter; - - static async create(options?: Record | string) { - const _options = - !!options && typeof options === "object" - ? options - : ((await getOptionsFromFile( - join(process.cwd(), options ?? CONFIGURATION_FILE), - )) ?? {}); - - return new Linter(_options); - } - - constructor(options: any) { - const linterBuilder = new wasm.LinterBuilder(); - this.linter = linterBuilder.configure(options).build(); - } - - /** - * Lints the given target. - * - * @param target The target to lint. - * @param rule The rule to lint. If not provided, all rules will be run. - * @returns A list of lint errors. - */ - lint(target: LintTarget, rule?: string): Promise { - return rule - ? this.linter.lint_only_rule(rule, target) - : this.linter.lint(target); - } -} - -async function getOptionsFromFile(filePath: string) { - try { - const file = await readFile(filePath, "utf8"); - const options = JSON.parse(file); - return options; - } catch (err) { - console.error( - `Could not read a valid options file at ${filePath}. Proceeding with default (empty) options.`, - ); - console.error(err); - } -} diff --git a/packages/supa-mdx-lint/tests/linter.test.ts b/packages/supa-mdx-lint/tests/linter.test.ts deleted file mode 100644 index 6f8ee62..0000000 --- a/packages/supa-mdx-lint/tests/linter.test.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { describe, it, expect } from "vitest"; -import { Linter, type LintTarget } from "../src"; - -describe("Linter", () => { - it("should lint a valid mdx file", async () => { - const linter = await Linter.create(); - const target: LintTarget = { - _type: "string", - path: null, - text: `# Hello - -This is a valid mdx file. -`, - }; - const errors = await linter.lint(target); - expect(errors).toEqual([]); - }); - - it("should lint an invalid mdx file", async () => { - const linter = await Linter.create(); - const target: LintTarget = { - _type: "string", - path: null, - text: `# Hello Bad Heading - -This is an invalid mdx file. -`, - }; - const errors = await linter.lint(target); - expect(errors.length).toEqual(1); - }); -}); diff --git a/packages/supa-mdx-lint/tsconfig.json b/packages/supa-mdx-lint/tsconfig.json deleted file mode 100644 index d721a29..0000000 --- a/packages/supa-mdx-lint/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "module": "ESNext", - "moduleResolution": "node", - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "declaration": true, - "outDir": "./dist" - }, - "include": ["src/**/*.ts", "pkg/**/*.d.ts"], - "exclude": ["node_modules", "**/*.test.ts"] -}