diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cae156eb66c..998734e78c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -297,9 +297,64 @@ jobs: api-key: ${{ secrets.NITRO_API_KEY }} comment-mode: "review" + verify-nitro-npm-package: + name: Verify Nitro npm package + runs-on: ubuntu-latest + needs: check-changes + if: needs.check-changes.outputs.src_changes == 'true' + steps: + - name: Checkout Repository + uses: actions/checkout@v6 + with: + show-progress: false + + - name: Setup Node + uses: actions/setup-node@v6 + with: + node-version: 24 + + - name: Enable corepack + run: corepack enable + + - name: Install dependencies + working-directory: src/Nitro/CommandLine/src/npm/chillicream-nitro + run: yarn install --immutable + + - name: Build + working-directory: src/Nitro/CommandLine/src/npm/chillicream-nitro + run: yarn build + + - name: Inject optionalDependencies + working-directory: src/Nitro/CommandLine/src/npm/chillicream-nitro + shell: bash + run: | + set -euo pipefail + jq --arg v "0.0.0-ci" ' + .optionalDependencies = { + "@chillicream/nitro-linux-arm64": $v, + "@chillicream/nitro-linux-musl-x64": $v, + "@chillicream/nitro-linux-x64": $v, + "@chillicream/nitro-osx-arm64": $v, + "@chillicream/nitro-osx-x64": $v, + "@chillicream/nitro-win-x64": $v, + "@chillicream/nitro-win-x86": $v + } + ' package.json > package.json.tmp + mv package.json.tmp package.json + + - name: Pack + working-directory: src/Nitro/CommandLine/src/npm/chillicream-nitro + run: npm pack --dry-run + ci-status-check: name: "CI Status Check" - needs: [library-tests, website-tests, validate-nitro-client] + needs: + [ + library-tests, + website-tests, + validate-nitro-client, + verify-nitro-npm-package, + ] if: always() runs-on: ubuntu-latest steps: @@ -308,4 +363,5 @@ jobs: if: | always() && (needs.library-tests.result == 'failure' || - needs.website-tests.result == 'failure') + needs.website-tests.result == 'failure' || + needs.verify-nitro-npm-package.result == 'failure') diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f3b46c97747..ee18792924b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -99,12 +99,11 @@ jobs: strategy: matrix: include: - # Linux (x64) + # Linux - os: ubuntu-22.04 rid: linux-x64 - os: ubuntu-22.04 rid: linux-musl-x64 - # Linux (arm64 on ARM runner!) - os: ubuntu-24.04-arm rid: linux-arm64 # macOS @@ -117,7 +116,7 @@ jobs: rid: win-x64 - os: windows-2025 rid: win-x86 - # Windows (arm64 on ARM runner!) + # Commented, since azure/artifact-signing-action does not currently support ARM. # - os: windows-11-arm # rid: win-arm64 @@ -137,8 +136,8 @@ jobs: - name: 🏷 Get the version from tag (Unix) if: runner.os != 'Windows' - run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV shell: bash + run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - name: 📦 Publish binary (Windows) if: runner.os == 'Windows' @@ -152,9 +151,9 @@ jobs: - name: 📦 Publish binary (Unix) if: runner.os != 'Windows' + shell: bash run: | ./build.sh publishaot --SemVersion $GIT_TAG --RuntimeIdentifier ${{ matrix.rid }} --Configuration Release - shell: bash env: NitroApiClientId: ${{ secrets.NITRO_API_CLIENT_ID }} NitroIdentityClientId: ${{ secrets.NITRO_IDENTITY_CLIENT_ID }} @@ -238,15 +237,15 @@ jobs: - name: 📦 Zip binary (macOS) if: runner.os == 'macOS' + shell: bash run: | zip -j nitro-${{ matrix.rid }}.zip publish/nitro - shell: bash - name: 📦 Tar binary (Linux) if: runner.os == 'Linux' + shell: bash run: | tar -czf nitro-${{ matrix.rid }}.tar.gz -C publish nitro - shell: bash - name: 🖋️ Notarize binary (macOS) if: runner.os == 'macOS' @@ -296,14 +295,31 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - publish-nitro-cli-npm: - name: 🧱 Publish Nitro CLI to npm + publish-nitro-cli-platforms: + name: 🧱 Publish Nitro CLI (${{ matrix.rid }}) to npm runs-on: ubuntu-latest needs: [build-nitro-cli] if: startsWith(github.ref, 'refs/tags/') permissions: contents: write id-token: write + strategy: + matrix: + include: + - rid: linux-x64 + binary: nitro + - rid: linux-musl-x64 + binary: nitro + - rid: linux-arm64 + binary: nitro + - rid: osx-x64 + binary: nitro + - rid: osx-arm64 + binary: nitro + - rid: win-x64 + binary: nitro.exe + - rid: win-x86 + binary: nitro.exe steps: - name: 📦 Checkout @@ -316,96 +332,148 @@ jobs: registry-url: ${{ vars.NPM_REGISTRY_URL }} scope: "@chillicream" - - name: 🧰 Enable corepack - run: corepack enable - - - name: 📥 Download all packaged nitro binaries + - name: 📥 Download nitro binary uses: actions/download-artifact@v8 with: - pattern: nitro-* - merge-multiple: true - path: dist-archives + name: nitro-${{ matrix.rid }} + path: dist - name: 🏷 Get the version from tag run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - - name: 🗂️ Move binaries to npm package + - name: 🗂️ Stage binary in package directory + shell: bash + working-directory: src/Nitro/CommandLine/src/npm/chillicream-nitro-${{ matrix.rid }} run: | - PACKAGE_DIR="src/Nitro/CommandLine/src/chillicream-nitro" - - for archive in dist-archives/nitro-*; do - base=$(basename "$archive") - - case "$base" in - nitro-*.zip) - rid=${base#nitro-} - rid=${rid%.zip} - echo "Unpacking $archive -> $PACKAGE_DIR/$rid" - mkdir -p "$PACKAGE_DIR/$rid" - unzip -q "$archive" -d "$PACKAGE_DIR/$rid" - ;; - nitro-*.tar.gz) - rid=${base#nitro-} - rid=${rid%.tar.gz} - echo "Unpacking $archive -> $PACKAGE_DIR/$rid" - mkdir -p "$PACKAGE_DIR/$rid" - tar -xzf "$archive" -C "$PACKAGE_DIR/$rid" - ;; - *) - echo "Skipping unknown artifact: $archive" - ;; - esac - done - - # Ensure unix binaries are executable - chmod +x $PACKAGE_DIR/linux-x64/nitro || true - chmod +x $PACKAGE_DIR/linux-musl-x64/nitro || true - chmod +x $PACKAGE_DIR/linux-arm64/nitro || true - chmod +x $PACKAGE_DIR/osx-x64/nitro || true - chmod +x $PACKAGE_DIR/osx-arm64/nitro || true - - # Ensure cli.js is executable - chmod +x $PACKAGE_DIR/cli.js - - - name: 🔍 Install dependencies - working-directory: src/Nitro/CommandLine/src/chillicream-nitro - run: yarn install --immutable - - - name: 📥 Install npm@11.9.0 - run: npm install -g npm@11.9.0 + set -euo pipefail + archive="$GITHUB_WORKSPACE/dist/nitro-${{ matrix.rid }}.tar.gz" + if [ ! -f "$archive" ]; then + archive="$GITHUB_WORKSPACE/dist/nitro-${{ matrix.rid }}.zip" + fi + case "$archive" in + *.tar.gz) tar -xzf "$archive" ;; + *.zip) unzip -q "$archive" ;; + esac + if [ "${{ matrix.binary }}" = "nitro" ]; then + chmod +x "${{ matrix.binary }}" + fi - name: 🏷️ Set version - working-directory: src/Nitro/CommandLine/src/chillicream-nitro - run: npm version $GIT_TAG + working-directory: src/Nitro/CommandLine/src/npm/chillicream-nitro-${{ matrix.rid }} + run: npm version "$GIT_TAG" --no-git-tag-version --allow-same-version - name: 📦 Create tarball - working-directory: src/Nitro/CommandLine/src/chillicream-nitro + working-directory: src/Nitro/CommandLine/src/npm/chillicream-nitro-${{ matrix.rid }} run: npm pack - name: 🚀 Publish tarball to npm - working-directory: src/Nitro/CommandLine/src/chillicream-nitro + working-directory: src/Nitro/CommandLine/src/npm/chillicream-nitro-${{ matrix.rid }} + shell: bash + run: | + npm publish "./chillicream-nitro-${{ matrix.rid }}-${GIT_TAG}.tgz" \ + --access public \ + --registry="${{ vars.NPM_REGISTRY_URL }}" + + - name: 📤 Upload tarball as artifact + uses: actions/upload-artifact@v7 + with: + name: chillicream-nitro-${{ matrix.rid }}-${{ env.GIT_TAG }}.tgz + path: src/Nitro/CommandLine/src/npm/chillicream-nitro-${{ matrix.rid }}/chillicream-nitro-${{ matrix.rid }}-${{ env.GIT_TAG }}.tgz + + - name: 📤 Attach tarball to GitHub release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + working-directory: src/Nitro/CommandLine/src/npm/chillicream-nitro-${{ matrix.rid }} run: | - TARBALL="chillicream-nitro-${GIT_TAG}.tgz" + gh release upload "${{ github.ref_name }}" "chillicream-nitro-${{ matrix.rid }}-${{ github.ref_name }}.tgz" --repo "${{ github.repository }}" + + publish-nitro-cli-npm: + name: 🧱 Publish Nitro CLI to npm + runs-on: ubuntu-latest + needs: [publish-nitro-cli-platforms] + if: startsWith(github.ref, 'refs/tags/') + permissions: + contents: write + id-token: write + steps: + - name: 📦 Checkout + uses: actions/checkout@v6 + + - name: 🧰 Setup Node + uses: actions/setup-node@v6 + with: + node-version: 24 + registry-url: ${{ vars.NPM_REGISTRY_URL }} + scope: "@chillicream" + + - name: 🏷 Get the version from tag + run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: 🏷 Compute dist-tag + shell: bash + run: | if [[ "$GIT_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - DIST_TAG="latest" + echo "DIST_TAG=latest" >> $GITHUB_ENV + elif [[ "$GIT_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+-rc\. ]]; then + echo "DIST_TAG=rc" >> $GITHUB_ENV else - DIST_TAG="preview" + echo "DIST_TAG=preview" >> $GITHUB_ENV fi - npm publish "./${TARBALL}" --access public --registry=${{ vars.NPM_REGISTRY_URL }} --tag "${DIST_TAG}" + - name: 🧰 Enable corepack + run: corepack enable + + - name: 📥 Install dependencies + working-directory: src/Nitro/CommandLine/src/npm/chillicream-nitro + run: yarn install --immutable + + - name: 🏗️ Build + working-directory: src/Nitro/CommandLine/src/npm/chillicream-nitro + run: yarn build + + - name: 🏷️ Bump version and inject optionalDependencies + working-directory: src/Nitro/CommandLine/src/npm/chillicream-nitro shell: bash + run: | + set -euo pipefail + npm version "$GIT_TAG" --no-git-tag-version --allow-same-version + jq --arg v "$GIT_TAG" ' + .optionalDependencies = { + "@chillicream/nitro-linux-arm64": $v, + "@chillicream/nitro-linux-musl-x64": $v, + "@chillicream/nitro-linux-x64": $v, + "@chillicream/nitro-osx-arm64": $v, + "@chillicream/nitro-osx-x64": $v, + "@chillicream/nitro-win-x64": $v, + "@chillicream/nitro-win-x86": $v + } + ' package.json > package.json.tmp + mv package.json.tmp package.json + + - name: 📦 Create tarball + working-directory: src/Nitro/CommandLine/src/npm/chillicream-nitro + run: npm pack + + - name: 🚀 Publish tarball to npm + working-directory: src/Nitro/CommandLine/src/npm/chillicream-nitro + shell: bash + run: | + npm publish "./chillicream-nitro-${GIT_TAG}.tgz" \ + --access public \ + --registry="${{ vars.NPM_REGISTRY_URL }}" \ + --tag "${DIST_TAG}" - name: 📤 Upload tarball as artifact uses: actions/upload-artifact@v7 with: name: chillicream-nitro-${{ env.GIT_TAG }}.tgz - path: src/Nitro/CommandLine/src/chillicream-nitro/chillicream-nitro-${{ env.GIT_TAG }}.tgz + path: src/Nitro/CommandLine/src/npm/chillicream-nitro/chillicream-nitro-${{ env.GIT_TAG }}.tgz - name: 📤 Attach tarball to GitHub release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - working-directory: src/Nitro/CommandLine/src/chillicream-nitro + working-directory: src/Nitro/CommandLine/src/npm/chillicream-nitro run: | gh release upload "${{ github.ref_name }}" "chillicream-nitro-${{ github.ref_name }}.tgz" --repo "${{ github.repository }}" diff --git a/src/Nitro/CommandLine/src/chillicream-nitro/.gitignore b/src/Nitro/CommandLine/src/chillicream-nitro/.gitignore deleted file mode 100644 index f03eaec0604..00000000000 --- a/src/Nitro/CommandLine/src/chillicream-nitro/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/sdks -!.yarn/versions - -# Whether you use PnP or not, the node_modules folder is often used to store -# build artifacts that should be gitignored -node_modules - -# Swap the comments on the following lines if you wish to use zero-installs -# In that case, don't forget to run `yarn config set enableGlobalCache false`! -# Documentation here: https://yarnpkg.com/features/caching#zero-installs - -#!.yarn/cache -.pnp.* diff --git a/src/Nitro/CommandLine/src/chillicream-nitro/cli.js b/src/Nitro/CommandLine/src/chillicream-nitro/cli.js deleted file mode 100755 index 65c93937c9e..00000000000 --- a/src/Nitro/CommandLine/src/chillicream-nitro/cli.js +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env node -"use strict"; - -import { join, dirname } from "path"; -import { fileURLToPath } from "url"; -import { spawn } from "child_process"; -import { family, GLIBC, MUSL } from "detect-libc"; - -const __dirname = dirname(fileURLToPath(import.meta.url)); - -async function resolveBinary() { - const { platform, arch } = process; - - const binaries = { - darwin: { - x64: "osx-x64/nitro", - arm64: "osx-arm64/nitro", - }, - win32: { - x64: "win-x64/nitro.exe", - ia32: "win-x86/nitro.exe", - arm64: "win-arm64/nitro.exe", - }, - linux: { - x64: async () => { - const libc = await family(); - - if (libc === GLIBC) { - return "linux-x64/nitro"; - } else if (libc === MUSL) { - return "linux-musl-x64/nitro"; - } - - return null; - }, - arm64: "linux-arm64/nitro", - }, - }; - - const binary = binaries[platform]?.[arch]; - if (!binary) { - return null; - } - - const binaryPath = typeof binary === "function" ? await binary() : binary; - return binaryPath ? join(__dirname, binaryPath) : null; -} - -const bin = await resolveBinary(); -const input = process.argv.slice(2); - -if (bin !== null) { - spawn(bin, input, { stdio: "inherit" }).on("exit", process.exit); -} else { - throw new Error( - `Platform "${process.platform} (${process.arch})" not supported.` - ); -} diff --git a/src/Nitro/CommandLine/src/chillicream-nitro/yarn.lock b/src/Nitro/CommandLine/src/chillicream-nitro/yarn.lock deleted file mode 100644 index f68a7f78e19..00000000000 --- a/src/Nitro/CommandLine/src/chillicream-nitro/yarn.lock +++ /dev/null @@ -1,23 +0,0 @@ -# This file is generated by running "yarn install" inside your project. -# Manual changes might be lost - proceed with caution! - -__metadata: - version: 8 - cacheKey: 10c0 - -"@chillicream/nitro@workspace:.": - version: 0.0.0-use.local - resolution: "@chillicream/nitro@workspace:." - dependencies: - detect-libc: "npm:^2.0.4" - bin: - nitro: cli.js - languageName: unknown - linkType: soft - -"detect-libc@npm:^2.0.4": - version: 2.0.4 - resolution: "detect-libc@npm:2.0.4" - checksum: 10c0/c15541f836eba4b1f521e4eecc28eefefdbc10a94d3b8cb4c507689f332cc111babb95deda66f2de050b22122113189986d5190be97d51b5a2b23b938415e67c - languageName: node - linkType: hard diff --git a/src/Nitro/CommandLine/src/npm/chillicream-nitro-linux-arm64/package.json b/src/Nitro/CommandLine/src/npm/chillicream-nitro-linux-arm64/package.json new file mode 100644 index 00000000000..dde7bcd67a7 --- /dev/null +++ b/src/Nitro/CommandLine/src/npm/chillicream-nitro-linux-arm64/package.json @@ -0,0 +1,32 @@ +{ + "name": "@chillicream/nitro-linux-arm64", + "version": "0.0.0", + "description": "Nitro CLI binary for linux-arm64 (glibc)", + "homepage": "https://chillicream.com", + "repository": { + "type": "git", + "url": "https://github.com/ChilliCream/graphql-platform", + "directory": "src/Nitro/CommandLine/src/npm/chillicream-nitro-linux-arm64" + }, + "bugs": { + "url": "https://github.com/ChilliCream/graphql-platform/issues" + }, + "author": { + "name": "ChilliCream", + "url": "https://chillicream.com", + "email": "info@chillicream.com" + }, + "license": "MIT", + "os": [ + "linux" + ], + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "files": [ + "nitro" + ] +} diff --git a/src/Nitro/CommandLine/src/npm/chillicream-nitro-linux-musl-x64/package.json b/src/Nitro/CommandLine/src/npm/chillicream-nitro-linux-musl-x64/package.json new file mode 100644 index 00000000000..3292c8b559a --- /dev/null +++ b/src/Nitro/CommandLine/src/npm/chillicream-nitro-linux-musl-x64/package.json @@ -0,0 +1,32 @@ +{ + "name": "@chillicream/nitro-linux-musl-x64", + "version": "0.0.0", + "description": "Nitro CLI binary for linux-musl-x64", + "homepage": "https://chillicream.com", + "repository": { + "type": "git", + "url": "https://github.com/ChilliCream/graphql-platform", + "directory": "src/Nitro/CommandLine/src/npm/chillicream-nitro-linux-musl-x64" + }, + "bugs": { + "url": "https://github.com/ChilliCream/graphql-platform/issues" + }, + "author": { + "name": "ChilliCream", + "url": "https://chillicream.com", + "email": "info@chillicream.com" + }, + "license": "MIT", + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "files": [ + "nitro" + ] +} diff --git a/src/Nitro/CommandLine/src/npm/chillicream-nitro-linux-x64/package.json b/src/Nitro/CommandLine/src/npm/chillicream-nitro-linux-x64/package.json new file mode 100644 index 00000000000..c9aa1360b34 --- /dev/null +++ b/src/Nitro/CommandLine/src/npm/chillicream-nitro-linux-x64/package.json @@ -0,0 +1,32 @@ +{ + "name": "@chillicream/nitro-linux-x64", + "version": "0.0.0", + "description": "Nitro CLI binary for linux-x64 (glibc)", + "homepage": "https://chillicream.com", + "repository": { + "type": "git", + "url": "https://github.com/ChilliCream/graphql-platform", + "directory": "src/Nitro/CommandLine/src/npm/chillicream-nitro-linux-x64" + }, + "bugs": { + "url": "https://github.com/ChilliCream/graphql-platform/issues" + }, + "author": { + "name": "ChilliCream", + "url": "https://chillicream.com", + "email": "info@chillicream.com" + }, + "license": "MIT", + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "files": [ + "nitro" + ] +} diff --git a/src/Nitro/CommandLine/src/npm/chillicream-nitro-osx-arm64/package.json b/src/Nitro/CommandLine/src/npm/chillicream-nitro-osx-arm64/package.json new file mode 100644 index 00000000000..6248dcd4cf7 --- /dev/null +++ b/src/Nitro/CommandLine/src/npm/chillicream-nitro-osx-arm64/package.json @@ -0,0 +1,29 @@ +{ + "name": "@chillicream/nitro-osx-arm64", + "version": "0.0.0", + "description": "Nitro CLI binary for osx-arm64", + "homepage": "https://chillicream.com", + "repository": { + "type": "git", + "url": "https://github.com/ChilliCream/graphql-platform", + "directory": "src/Nitro/CommandLine/src/npm/chillicream-nitro-osx-arm64" + }, + "bugs": { + "url": "https://github.com/ChilliCream/graphql-platform/issues" + }, + "author": { + "name": "ChilliCream", + "url": "https://chillicream.com", + "email": "info@chillicream.com" + }, + "license": "MIT", + "os": [ + "darwin" + ], + "cpu": [ + "arm64" + ], + "files": [ + "nitro" + ] +} diff --git a/src/Nitro/CommandLine/src/npm/chillicream-nitro-osx-x64/package.json b/src/Nitro/CommandLine/src/npm/chillicream-nitro-osx-x64/package.json new file mode 100644 index 00000000000..806cbadc054 --- /dev/null +++ b/src/Nitro/CommandLine/src/npm/chillicream-nitro-osx-x64/package.json @@ -0,0 +1,29 @@ +{ + "name": "@chillicream/nitro-osx-x64", + "version": "0.0.0", + "description": "Nitro CLI binary for osx-x64", + "homepage": "https://chillicream.com", + "repository": { + "type": "git", + "url": "https://github.com/ChilliCream/graphql-platform", + "directory": "src/Nitro/CommandLine/src/npm/chillicream-nitro-osx-x64" + }, + "bugs": { + "url": "https://github.com/ChilliCream/graphql-platform/issues" + }, + "author": { + "name": "ChilliCream", + "url": "https://chillicream.com", + "email": "info@chillicream.com" + }, + "license": "MIT", + "os": [ + "darwin" + ], + "cpu": [ + "x64" + ], + "files": [ + "nitro" + ] +} diff --git a/src/Nitro/CommandLine/src/npm/chillicream-nitro-win-x64/package.json b/src/Nitro/CommandLine/src/npm/chillicream-nitro-win-x64/package.json new file mode 100644 index 00000000000..9fee60112a2 --- /dev/null +++ b/src/Nitro/CommandLine/src/npm/chillicream-nitro-win-x64/package.json @@ -0,0 +1,29 @@ +{ + "name": "@chillicream/nitro-win-x64", + "version": "0.0.0", + "description": "Nitro CLI binary for win-x64", + "homepage": "https://chillicream.com", + "repository": { + "type": "git", + "url": "https://github.com/ChilliCream/graphql-platform", + "directory": "src/Nitro/CommandLine/src/npm/chillicream-nitro-win-x64" + }, + "bugs": { + "url": "https://github.com/ChilliCream/graphql-platform/issues" + }, + "author": { + "name": "ChilliCream", + "url": "https://chillicream.com", + "email": "info@chillicream.com" + }, + "license": "MIT", + "os": [ + "win32" + ], + "cpu": [ + "x64" + ], + "files": [ + "nitro.exe" + ] +} diff --git a/src/Nitro/CommandLine/src/npm/chillicream-nitro-win-x86/package.json b/src/Nitro/CommandLine/src/npm/chillicream-nitro-win-x86/package.json new file mode 100644 index 00000000000..4a57aeb3b8a --- /dev/null +++ b/src/Nitro/CommandLine/src/npm/chillicream-nitro-win-x86/package.json @@ -0,0 +1,29 @@ +{ + "name": "@chillicream/nitro-win-x86", + "version": "0.0.0", + "description": "Nitro CLI binary for win-x86", + "homepage": "https://chillicream.com", + "repository": { + "type": "git", + "url": "https://github.com/ChilliCream/graphql-platform", + "directory": "src/Nitro/CommandLine/src/npm/chillicream-nitro-win-x86" + }, + "bugs": { + "url": "https://github.com/ChilliCream/graphql-platform/issues" + }, + "author": { + "name": "ChilliCream", + "url": "https://chillicream.com", + "email": "info@chillicream.com" + }, + "license": "MIT", + "os": [ + "win32" + ], + "cpu": [ + "ia32" + ], + "files": [ + "nitro.exe" + ] +} diff --git a/src/Nitro/CommandLine/src/chillicream-nitro/.editorconfig b/src/Nitro/CommandLine/src/npm/chillicream-nitro/.editorconfig similarity index 100% rename from src/Nitro/CommandLine/src/chillicream-nitro/.editorconfig rename to src/Nitro/CommandLine/src/npm/chillicream-nitro/.editorconfig diff --git a/src/Nitro/CommandLine/src/chillicream-nitro/.gitattributes b/src/Nitro/CommandLine/src/npm/chillicream-nitro/.gitattributes similarity index 100% rename from src/Nitro/CommandLine/src/chillicream-nitro/.gitattributes rename to src/Nitro/CommandLine/src/npm/chillicream-nitro/.gitattributes diff --git a/src/Nitro/CommandLine/src/npm/chillicream-nitro/.gitignore b/src/Nitro/CommandLine/src/npm/chillicream-nitro/.gitignore new file mode 100644 index 00000000000..a24b6406537 --- /dev/null +++ b/src/Nitro/CommandLine/src/npm/chillicream-nitro/.gitignore @@ -0,0 +1,11 @@ +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions + +node_modules +dist + +.pnp.* diff --git a/src/Nitro/CommandLine/src/chillicream-nitro/.yarnrc.yml b/src/Nitro/CommandLine/src/npm/chillicream-nitro/.yarnrc.yml similarity index 100% rename from src/Nitro/CommandLine/src/chillicream-nitro/.yarnrc.yml rename to src/Nitro/CommandLine/src/npm/chillicream-nitro/.yarnrc.yml diff --git a/src/Nitro/CommandLine/src/chillicream-nitro/README.md b/src/Nitro/CommandLine/src/npm/chillicream-nitro/README.md similarity index 100% rename from src/Nitro/CommandLine/src/chillicream-nitro/README.md rename to src/Nitro/CommandLine/src/npm/chillicream-nitro/README.md diff --git a/src/Nitro/CommandLine/src/chillicream-nitro/package.json b/src/Nitro/CommandLine/src/npm/chillicream-nitro/package.json similarity index 72% rename from src/Nitro/CommandLine/src/chillicream-nitro/package.json rename to src/Nitro/CommandLine/src/npm/chillicream-nitro/package.json index a090f3a4241..b4009b425bb 100644 --- a/src/Nitro/CommandLine/src/chillicream-nitro/package.json +++ b/src/Nitro/CommandLine/src/npm/chillicream-nitro/package.json @@ -6,7 +6,7 @@ "repository": { "type": "git", "url": "https://github.com/ChilliCream/graphql-platform", - "directory": "src/Nitro/CommandLine/src/chillicream-nitro" + "directory": "src/Nitro/CommandLine/src/npm/chillicream-nitro" }, "bugs": { "url": "https://github.com/ChilliCream/graphql-platform/issues" @@ -27,22 +27,23 @@ "url": "https://opencollective.com/chillicream" }, "type": "module", - "bin": { - "nitro": "cli.js" + "engines": { + "node": ">=20.6.0" }, + "bin": "./dist/cli.js", "files": [ - "cli.js", - "linux-x64/", - "linux-musl-x64/", - "linux-arm64/", - "osx-x64/", - "osx-arm64/", - "win-x64/", - "win-x86/", - "win-arm64/" + "dist", + "README.md" ], + "scripts": { + "build": "tsc" + }, "packageManager": "yarn@4.9.4", "dependencies": { "detect-libc": "^2.0.4" + }, + "devDependencies": { + "@types/node": "^24.0.0", + "typescript": "^5.9.0" } } diff --git a/src/Nitro/CommandLine/src/npm/chillicream-nitro/src/cli.ts b/src/Nitro/CommandLine/src/npm/chillicream-nitro/src/cli.ts new file mode 100644 index 00000000000..e2ab5360d7c --- /dev/null +++ b/src/Nitro/CommandLine/src/npm/chillicream-nitro/src/cli.ts @@ -0,0 +1,87 @@ +#!/usr/bin/env node +import { spawn } from "node:child_process"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; +import { familySync, GLIBC, MUSL } from "detect-libc"; + +function resolveCandidates(): string[] { + const { platform, arch } = process; + + if (platform === "linux" && arch === "x64") { + const libc = familySync(); + if (libc === MUSL) { + return ["@chillicream/nitro-linux-musl-x64"]; + } + if (libc === GLIBC) { + return ["@chillicream/nitro-linux-x64"]; + } + return [ + "@chillicream/nitro-linux-x64", + "@chillicream/nitro-linux-musl-x64", + ]; + } + + const map: Record = { + "darwin-arm64": "@chillicream/nitro-osx-arm64", + "darwin-x64": "@chillicream/nitro-osx-x64", + "linux-arm64": "@chillicream/nitro-linux-arm64", + "win32-ia32": "@chillicream/nitro-win-x86", + "win32-x64": "@chillicream/nitro-win-x64", + }; + const pkg = map[`${platform}-${arch}`]; + return pkg ? [pkg] : []; +} + +function resolveBinary(): string | null { + const binaryName = process.platform === "win32" ? "nitro.exe" : "nitro"; + + for (const pkg of resolveCandidates()) { + try { + const pkgJson = fileURLToPath(import.meta.resolve(`${pkg}/package.json`)); + return join(dirname(pkgJson), binaryName); + } catch { + // try next candidate + } + } + return null; +} + +function describePlatform(): string { + const { platform, arch } = process; + if (platform === "linux") { + const libc = familySync(); + return libc ? `linux-${arch} (${libc})` : `linux-${arch}`; + } + return `${platform}-${arch}`; +} + +const bin = resolveBinary(); + +if (bin === null) { + console.error( + `Platform "${describePlatform()}" is not supported by @chillicream/nitro.`, + ); + process.exit(1); +} + +const child = spawn(bin, process.argv.slice(2), { stdio: "inherit" }); + +child.on("error", (error) => { + console.error( + `Failed to start @chillicream/nitro binary "${bin}": ${error.message}`, + ); + process.exit(1); +}); + +child.on("exit", (code, signal) => { + if (signal !== null) { + try { + process.kill(process.pid, signal); + return; + } catch { + process.exit(1); + } + } + + process.exit(code ?? 1); +}); diff --git a/src/Nitro/CommandLine/src/npm/chillicream-nitro/tsconfig.json b/src/Nitro/CommandLine/src/npm/chillicream-nitro/tsconfig.json new file mode 100644 index 00000000000..f00925c874a --- /dev/null +++ b/src/Nitro/CommandLine/src/npm/chillicream-nitro/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "noImplicitOverride": true, + "types": ["node"], + "rootDir": "./src", + "outDir": "./dist" + }, + "include": ["src/**/*"] +} diff --git a/src/Nitro/CommandLine/src/npm/chillicream-nitro/yarn.lock b/src/Nitro/CommandLine/src/npm/chillicream-nitro/yarn.lock new file mode 100644 index 00000000000..2ac2eca9724 --- /dev/null +++ b/src/Nitro/CommandLine/src/npm/chillicream-nitro/yarn.lock @@ -0,0 +1,61 @@ +# This file is generated by running "yarn install" inside your project. +# Manual changes might be lost - proceed with caution! + +__metadata: + version: 8 + cacheKey: 10c0 + +"@chillicream/nitro@workspace:.": + version: 0.0.0-use.local + resolution: "@chillicream/nitro@workspace:." + dependencies: + "@types/node": "npm:^24.0.0" + detect-libc: "npm:^2.0.4" + typescript: "npm:^5.9.0" + bin: + nitro: ./dist/cli.js + languageName: unknown + linkType: soft + +"@types/node@npm:^24.0.0": + version: 24.12.2 + resolution: "@types/node@npm:24.12.2" + dependencies: + undici-types: "npm:~7.16.0" + checksum: 10c0/710050c42f89075c4479e4e1e4c2532486b0c41b1e2a8a13ad88641c88b88cdaea87414e19224f30028719737bd70e327edcaa184d50e86b9418941edd7eb02b + languageName: node + linkType: hard + +"detect-libc@npm:^2.0.4": + version: 2.1.2 + resolution: "detect-libc@npm:2.1.2" + checksum: 10c0/acc675c29a5649fa1fb6e255f993b8ee829e510b6b56b0910666949c80c364738833417d0edb5f90e4e46be17228b0f2b66a010513984e18b15deeeac49369c4 + languageName: node + linkType: hard + +"typescript@npm:^5.9.0": + version: 5.9.3 + resolution: "typescript@npm:5.9.3" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10c0/6bd7552ce39f97e711db5aa048f6f9995b53f1c52f7d8667c1abdc1700c68a76a308f579cd309ce6b53646deb4e9a1be7c813a93baaf0a28ccd536a30270e1c5 + languageName: node + linkType: hard + +"typescript@patch:typescript@npm%3A^5.9.0#optional!builtin": + version: 5.9.3 + resolution: "typescript@patch:typescript@npm%3A5.9.3#optional!builtin::version=5.9.3&hash=5786d5" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10c0/ad09fdf7a756814dce65bc60c1657b40d44451346858eea230e10f2e95a289d9183b6e32e5c11e95acc0ccc214b4f36289dcad4bf1886b0adb84d711d336a430 + languageName: node + linkType: hard + +"undici-types@npm:~7.16.0": + version: 7.16.0 + resolution: "undici-types@npm:7.16.0" + checksum: 10c0/3033e2f2b5c9f1504bdc5934646cb54e37ecaca0f9249c983f7b1fc2e87c6d18399ebb05dc7fd5419e02b2e915f734d872a65da2e3eeed1813951c427d33cc9a + languageName: node + linkType: hard