From 782216c74a08c53056aac83c309147dc399dedfe Mon Sep 17 00:00:00 2001 From: Aymane Dara Hlamnach Date: Tue, 7 Jan 2025 08:59:03 +0100 Subject: [PATCH] chore: gh build actions (#88) --- .github/workflows/build.yaml | 87 ++++++++++++++++++++++++++++++++ package.json | 4 ++ packages/cli-kit/lib/node/cli.ts | 6 +-- packages/cli/bin/exec.js | 1 + packages/create-app/bin/exec.js | 1 + 5 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..50e8487 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,87 @@ +name: Build + +on: + push: + branches: + - main + paths: + - 'packages/**' + + pull_request: + paths: + - 'packages/**' + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js environment + uses: actions/setup-node@v4 + with: + node-version: 20 + + - uses: pnpm/action-setup@v2 + name: Install pnpm + with: + version: 9 + run_install: false + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache + 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 i --frozen-lockfile + + - name: Lint + run: pnpm lint + + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js environment + uses: actions/setup-node@v4 + with: + node-version: 20 + + - uses: pnpm/action-setup@v2 + name: Install pnpm + with: + version: 9 + run_install: false + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache + 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 i --frozen-lockfile + + - name: Build + run: pnpm build diff --git a/package.json b/package.json index fc2395e..f03eef3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,10 @@ { "type": "module", "private": true, + "packageManager": "pnpm@9.15.2", + "engines": { + "node": ">=20.10.0" + }, "scripts": { "build": "pnpm -r build", "lint": "eslint --fix packages/**/*.{ts,js,json}", diff --git a/packages/cli-kit/lib/node/cli.ts b/packages/cli-kit/lib/node/cli.ts index 2d5c30f..38d855e 100644 --- a/packages/cli-kit/lib/node/cli.ts +++ b/packages/cli-kit/lib/node/cli.ts @@ -31,7 +31,7 @@ function setupColorMode(): void { } } -function errorHandler(error: Error): never { +function handleError(error: Error): never { let suggestions: string[] = []; const message: string = error.message; @@ -55,10 +55,10 @@ export async function exec(options: ExecOptions): Promise { run(undefined, options.moduleUrl) .then(() => flush()) - .catch(errorHandler); + .catch(handleError); } -process.on('uncaughtException', errorHandler); +process.on('uncaughtException', handleError); export async function execCreate(cmdlet: string, options: ExecOptions): Promise { setupEnvVars(options); diff --git a/packages/cli/bin/exec.js b/packages/cli/bin/exec.js index 9bc3754..a9ec228 100755 --- a/packages/cli/bin/exec.js +++ b/packages/cli/bin/exec.js @@ -1,4 +1,5 @@ #!/usr/bin/env node +import process from 'node:process'; process.removeAllListeners('warning'); diff --git a/packages/create-app/bin/exec.js b/packages/create-app/bin/exec.js index eef5d8e..d89e624 100755 --- a/packages/create-app/bin/exec.js +++ b/packages/create-app/bin/exec.js @@ -1,4 +1,5 @@ #!/usr/bin/env node +import process from 'node:process'; process.removeAllListeners('warning');