diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2bbabd0..27f83db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -124,3 +124,140 @@ jobs: - name: Run Tests ๐ run: pnpm run test working-directory: ${{ matrix.package.path }} + + build-parser: + name: Build Parser Package ๐ฆ + needs: build-wasm + runs-on: ubuntu-latest + steps: + - name: Checkout Repository ๐ฅ + uses: actions/checkout@v4 + + - name: Setup Node.js ๐ + uses: actions/setup-node@v4 + with: + node-version: '20.x' + + - name: Setup pnpm ๐ฆ + uses: pnpm/action-setup@v2 + with: + version: 8.15.1 + + - name: Get pnpm store directory ๐ + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: Setup pnpm cache ๐๏ธ + uses: actions/cache@v3 + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install Dependencies ๐งถ + run: pnpm install + + - name: Install Parser Dependencies ๐ฆ + run: pnpm install + working-directory: parser + + - name: Download v15 WASM Artifacts ๐ฅ + uses: actions/download-artifact@v4 + with: + name: wasm-artifacts-v15 + path: versions/15/wasm/ + + - name: Download v16 WASM Artifacts ๐ฅ + uses: actions/download-artifact@v4 + with: + name: wasm-artifacts-v16 + path: versions/16/wasm/ + + - name: Download v17 WASM Artifacts ๐ฅ + uses: actions/download-artifact@v4 + with: + name: wasm-artifacts-v17 + path: versions/17/wasm/ + + - name: Build Parser ๐ + run: pnpm run build + working-directory: parser + + - name: Upload Parser Artifacts ๐ฆ + uses: actions/upload-artifact@v4 + with: + name: parser-artifacts + path: parser/wasm/ + retention-days: 1 + + test-parser: + name: Test Parser on ${{ matrix.os }} ${{ matrix.os == 'ubuntu-latest' && '๐ง' || matrix.os == 'macos-latest' && '๐' || '๐ช' }} + needs: build-parser + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + fail-fast: false + runs-on: ${{ matrix.os }} + steps: + - name: Checkout Repository ๐ฅ + uses: actions/checkout@v4 + + - name: Setup Node.js ๐ + uses: actions/setup-node@v4 + with: + node-version: '20.x' + + - name: Setup pnpm ๐ฆ + uses: pnpm/action-setup@v2 + with: + version: 8.15.1 + + - name: Get pnpm store directory ๐ + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: Setup pnpm cache ๐๏ธ + uses: actions/cache@v3 + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install Dependencies ๐งถ + run: pnpm install + + - name: Install Parser Dependencies ๐ฆ + run: pnpm install + working-directory: parser + + - name: Download v15 WASM Artifacts ๐ฅ + uses: actions/download-artifact@v4 + with: + name: wasm-artifacts-v15 + path: versions/15/wasm/ + + - name: Download v16 WASM Artifacts ๐ฅ + uses: actions/download-artifact@v4 + with: + name: wasm-artifacts-v16 + path: versions/16/wasm/ + + - name: Download v17 WASM Artifacts ๐ฅ + uses: actions/download-artifact@v4 + with: + name: wasm-artifacts-v17 + path: versions/17/wasm/ + + - name: Download Parser Artifacts ๐ฅ + uses: actions/download-artifact@v4 + with: + name: parser-artifacts + path: parser/wasm/ + + - name: Run Parser Tests ๐ + run: pnpm run test + working-directory: parser diff --git a/README.md b/README.md index ac2f4a6..4a9e00e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # libpg-query
-
+
@@ -30,7 +30,7 @@ Built to power [pgsql-parser](https://github.com/pyramation/pgsql-parser), this * ๐ **Node.js & Browser Support** โ Consistent behavior in any JS environment * ๐ฆ **No Native Builds Required** โ No compilation, no system-specific dependencies * ๐ง **Spec-Accurate Parsing** โ Produces faithful, standards-compliant ASTs -* ๐ **Production-Grade** โ Millions of downloads powering 1000s of projects +* ๐ **Production-Grade** โ Millions of downloads and trusted by countless projects and top teams ## ๐ For Round-trip Codegen diff --git a/full/README.md b/full/README.md index d723384..9dff5da 100644 --- a/full/README.md +++ b/full/README.md @@ -1,7 +1,7 @@ # @libpg-query/parser
-
+
@@ -30,7 +30,7 @@ Built to power [pgsql-parser](https://github.com/pyramation/pgsql-parser), this * ๐ **Node.js & Browser Support** โ Consistent behavior in any JS environment * ๐ฆ **No Native Builds Required** โ No compilation, no system-specific dependencies * ๐ง **Spec-Accurate Parsing** โ Produces faithful, standards-compliant ASTs -* ๐ **Production-Grade** โ Millions of downloads powering 1000s of projects +* ๐ **Production-Grade** โ Millions of downloads and trusted by countless projects and top teams ## ๐ For Round-trip Codegen diff --git a/package.json b/package.json index 5766b8c..7bdd3df 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,10 @@ "publish:types": "node scripts/publish-types.js", "publish:enums": "node scripts/publish-enums.js", "publish:versions": "node scripts/publish-versions.js", - "update:versions-types": "node scripts/update-versions-types.js" + "update:versions-types": "node scripts/update-versions-types.js", + "build:parser": "pnpm --filter @pgsql/parser build", + "test:parser": "pnpm --filter @pgsql/parser test", + "publish:parser": "pnpm --filter @pgsql/parser publish" }, "devDependencies": { "@types/node": "^20.0.0", diff --git a/parser/.gitignore b/parser/.gitignore new file mode 100644 index 0000000..261743c --- /dev/null +++ b/parser/.gitignore @@ -0,0 +1,10 @@ +node_modules/ +dist/ +dist-esm/ +*.log +.DS_Store +src/wasm/*.wasm +src/wasm/*.js +src/types/15/ +src/types/16/ +src/types/17/ \ No newline at end of file diff --git a/parser/Makefile.shared b/parser/Makefile.shared new file mode 100644 index 0000000..16f6956 --- /dev/null +++ b/parser/Makefile.shared @@ -0,0 +1,42 @@ +# Shared Makefile for building PostgreSQL parser WASM +VERSION ?= 17 +TAG_15 = 15-4.2.4 +TAG_16 = 16-5.2.0 +TAG_17 = 17-6.1.0 +TAG = $(TAG_$(VERSION)) + +# Emscripten flags +EMCC_CFLAGS = -O3 -flto -s WASM=1 -s TOTAL_MEMORY=16777216 \ + -s EXPORTED_FUNCTIONS="['_parse_sql']" \ + -s EXPORTED_RUNTIME_METHODS="['ccall','cwrap']" \ + -s MODULARIZE=1 \ + -s EXPORT_NAME="LibPGQuery$(VERSION)" + +.PHONY: all +all: clean download build-wasm + +.PHONY: download +download: + @echo "Downloading libpg_query $(TAG)..." + curl -L "https://github.com/pganalyze/libpg_query/archive/refs/tags/$(TAG).tar.gz" | tar -xz + mv libpg_query-$(TAG) libpg_query + +.PHONY: build-wasm +build-wasm: + @echo "Building WASM for PostgreSQL $(VERSION)..." + cd libpg_query && make build_shared + emcc $(EMCC_CFLAGS) \ + -I./libpg_query \ + ./wasm_wrapper.c \ + ./libpg_query/libpg_query.a \ + -o libpg-query.js + +.PHONY: clean +clean: + rm -rf libpg_query libpg-query.js libpg-query.wasm + +.PHONY: info +info: + @echo "Building PostgreSQL $(VERSION) parser" + @echo "Tag: $(TAG)" + @echo "Export name: LibPGQuery$(VERSION)" \ No newline at end of file diff --git a/parser/README.md b/parser/README.md new file mode 100644 index 0000000..459287c --- /dev/null +++ b/parser/README.md @@ -0,0 +1,130 @@ +# @pgsql/parser + +
+
+
-
+
@@ -30,7 +30,7 @@ Built to power [pgsql-parser](https://github.com/pyramation/pgsql-parser), this * ๐ **Node.js & Browser Support** โ Consistent behavior in any JS environment * ๐ฆ **No Native Builds Required** โ No compilation, no system-specific dependencies * ๐ง **Spec-Accurate Parsing** โ Produces faithful, standards-compliant ASTs -* ๐ **Production-Grade** โ Millions of downloads powering 1000s of projects +* ๐ **Production-Grade** โ Millions of downloads and trusted by countless projects and top teams ## ๐ For Round-trip Codegen diff --git a/versions/14/README.md b/versions/14/README.md index d44debd..489aa29 100644 --- a/versions/14/README.md +++ b/versions/14/README.md @@ -1,7 +1,7 @@ # libpg-query
-
+
@@ -30,7 +30,7 @@ Built to power [pgsql-parser](https://github.com/pyramation/pgsql-parser), this * ๐ **Node.js & Browser Support** โ Consistent behavior in any JS environment * ๐ฆ **No Native Builds Required** โ No compilation, no system-specific dependencies * ๐ง **Spec-Accurate Parsing** โ Produces faithful, standards-compliant ASTs -* ๐ **Production-Grade** โ Millions of downloads powering 1000s of projects +* ๐ **Production-Grade** โ Millions of downloads and trusted by countless projects and top teams ## ๐ For Round-trip Codegen diff --git a/versions/15/README.md b/versions/15/README.md index d44debd..489aa29 100644 --- a/versions/15/README.md +++ b/versions/15/README.md @@ -1,7 +1,7 @@ # libpg-query
-
+
@@ -30,7 +30,7 @@ Built to power [pgsql-parser](https://github.com/pyramation/pgsql-parser), this * ๐ **Node.js & Browser Support** โ Consistent behavior in any JS environment * ๐ฆ **No Native Builds Required** โ No compilation, no system-specific dependencies * ๐ง **Spec-Accurate Parsing** โ Produces faithful, standards-compliant ASTs -* ๐ **Production-Grade** โ Millions of downloads powering 1000s of projects +* ๐ **Production-Grade** โ Millions of downloads and trusted by countless projects and top teams ## ๐ For Round-trip Codegen diff --git a/versions/16/README.md b/versions/16/README.md index d44debd..489aa29 100644 --- a/versions/16/README.md +++ b/versions/16/README.md @@ -1,7 +1,7 @@ # libpg-query
-
+
@@ -30,7 +30,7 @@ Built to power [pgsql-parser](https://github.com/pyramation/pgsql-parser), this * ๐ **Node.js & Browser Support** โ Consistent behavior in any JS environment * ๐ฆ **No Native Builds Required** โ No compilation, no system-specific dependencies * ๐ง **Spec-Accurate Parsing** โ Produces faithful, standards-compliant ASTs -* ๐ **Production-Grade** โ Millions of downloads powering 1000s of projects +* ๐ **Production-Grade** โ Millions of downloads and trusted by countless projects and top teams ## ๐ For Round-trip Codegen diff --git a/versions/17/README.md b/versions/17/README.md index d44debd..489aa29 100644 --- a/versions/17/README.md +++ b/versions/17/README.md @@ -1,7 +1,7 @@ # libpg-query
-
+
@@ -30,7 +30,7 @@ Built to power [pgsql-parser](https://github.com/pyramation/pgsql-parser), this * ๐ **Node.js & Browser Support** โ Consistent behavior in any JS environment * ๐ฆ **No Native Builds Required** โ No compilation, no system-specific dependencies * ๐ง **Spec-Accurate Parsing** โ Produces faithful, standards-compliant ASTs -* ๐ **Production-Grade** โ Millions of downloads powering 1000s of projects +* ๐ **Production-Grade** โ Millions of downloads and trusted by countless projects and top teams ## ๐ For Round-trip Codegen