diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 423724a..8596e20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,63 +1,41 @@ -name: CI/CD Pipeline - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - build-and-test: - name: Node ${{ matrix.node-version }} - ${{ matrix.package-manager }} - runs-on: ubuntu-latest - permissions: - contents: read - - strategy: - matrix: - node-version: [20.x, 22.x] - package-manager: [npm, pnpm, yarn] - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - - - name: Enable Corepack - run: corepack enable - - - name: Install dependencies - run: ${{ matrix.package-manager }} install - - - name: Build package - run: ${{ matrix.package-manager }} run build - - - name: Smoke test built artifact - run: | - mkdir -p test-logs - node dist/create-next-quick.js --version > test-logs/smoke-test.txt 2>&1 - if [ $? -ne 0 ]; then cat test-logs/smoke-test.txt; exit 1; fi - cat test-logs/smoke-test.txt - - - name: Run tests and save logs - run: | - mkdir -p test-logs - ${{ matrix.package-manager }} test > test-logs/log.txt 2>&1 - - - name: Verify test success - run: grep "Tests passed successfully" test-logs/log.txt - - - name: Print test logs - run: cat test-logs/log.txt - - - name: Upload test logs - uses: actions/upload-artifact@v4 - if: always() - with: - name: test-logs-${{ matrix.node-version }}-${{ matrix.package-manager }} - path: test-logs/log.txt - retention-days: 5 +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build-and-test: + name: Build & Test + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 10.28.2 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build package + run: pnpm build + + - name: Smoke test + run: node dist/create-next-quick.js --version + + - name: Run tests + run: pnpm test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0b368ee..0dc9261 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -24,14 +24,14 @@ jobs: contents: write steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 with: fetch-depth: 0 - name: Install pnpm - uses: pnpm/action-setup@v3 + uses: pnpm/action-setup@v6 with: - version: 9 + version: 10.28.2 - name: Setup Node.js uses: actions/setup-node@v4 diff --git a/package.json b/package.json index 6c2dce2..a3816b3 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "javascript", "frontend" ], + "packageManager": "pnpm@10.28.2", "author": "gaureshpai", "license": "MIT", "repository": { diff --git a/src/lib/prompts.js b/src/lib/prompts.js index 1f10082..b017c4c 100644 --- a/src/lib/prompts.js +++ b/src/lib/prompts.js @@ -17,9 +17,16 @@ const ask = (query) => { return new Promise((resolve) => getRl().question(query, resolve)); }; +// biome-ignore lint/suspicious/noControlCharactersInRegex: ESC char is required to match ANSI escape codes +const ansiRegex = /\u001b\[[0-9;?]*[ -/]*[@-~]/g; +const stripAnsi = (str) => { + return str.replace(ansiRegex, ""); +}; + const getRenderedRowCount = (text, columns = process.stdout.columns ?? 80) => { const safeColumns = Math.max(columns || 80, 1); - return Math.max(1, Math.ceil(text.length / safeColumns)); + const visibleLength = stripAnsi(text).length; + return Math.max(1, Math.ceil(visibleLength / safeColumns)); }; const resolveConfirmInput = (input, defaultValue) => { @@ -228,7 +235,8 @@ const processQuestion = async (question) => { readline.clearLine(stdout, 0); readline.cursorTo(stdout, 0); - process.stdout.write(`${prefix} ${indexLabel}${label}${explanation}\n`); + const line = `${prefix} ${indexLabel}${label}${explanation}`; + process.stdout.write(`${line}\n`); }); };