From d28f20c85a4a7d7c03361d49a7682f6f947c0dbc Mon Sep 17 00:00:00 2001 From: Jiahao Guo Date: Wed, 22 Oct 2025 14:07:48 +0800 Subject: [PATCH 1/2] ci: migrate to trusted publishing --- .github/workflows/ci.yml | 9 ++++----- .node-version | 2 +- ...pdoc-parser-3bd33af3-91ce-47c4-8958-96e8a7bba14c.json | 7 +++++++ 3 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 change/@rightcapital-phpdoc-parser-3bd33af3-91ce-47c4-8958-96e8a7bba14c.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b90647e3..27c100a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,6 +79,9 @@ jobs: if: ${{ always() && !failure() && !cancelled() }} needs: [test, check-beachball-changefile] runs-on: ubuntu-latest + permissions: + id-token: write + contents: read steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 @@ -94,19 +97,15 @@ jobs: - name: Publish (development) if: github.repository == 'RightCapitalHQ/phpdoc-parser' && github.base_ref == github.event.repository.default_branch env: - NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + HEAD_REF: ${{ github.head_ref }} run: | - npm config set //registry.npmjs.org/:_authToken "${NPM_TOKEN}" preid="${HEAD_REF//\//-}".${{ github.run_number }}.${{ github.run_attempt }} npm --no-git-tag-version version prerelease --preid="${preid}" pnpm publish --no-git-checks --access public --tag development - name: Publish (main) if: github.repository == 'RightCapitalHQ/phpdoc-parser' && github.ref_name == github.event.repository.default_branch - env: - NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} run: | - npm config set //registry.npmjs.org/:_authToken "${NPM_TOKEN}" git config --local user.email "npm-publisher@rightcapital.com" git config --local user.name "GitHub Actions[bot]" pnpm beachball publish --access public --yes -m 'chore(release): applying package updates' diff --git a/.node-version b/.node-version index 818ab238..a03e161f 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -22.17.1 \ No newline at end of file +24.10.0 \ No newline at end of file diff --git a/change/@rightcapital-phpdoc-parser-3bd33af3-91ce-47c4-8958-96e8a7bba14c.json b/change/@rightcapital-phpdoc-parser-3bd33af3-91ce-47c4-8958-96e8a7bba14c.json new file mode 100644 index 00000000..3711234e --- /dev/null +++ b/change/@rightcapital-phpdoc-parser-3bd33af3-91ce-47c4-8958-96e8a7bba14c.json @@ -0,0 +1,7 @@ +{ + "comment": "ci: migrate to trusted publishing", + "type": "none", + "packageName": "@rightcapital/phpdoc-parser", + "email": "im@pyonpyon.today", + "dependentChangeType": "none" +} From 2cd7dd56df2ba0e859bc5d6ffc7d1215ee1bb614 Mon Sep 17 00:00:00 2001 From: Jiahao Guo Date: Wed, 22 Oct 2025 14:28:24 +0800 Subject: [PATCH 2/2] style: fix prettier issue --- CLAUDE.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CLAUDE.md b/CLAUDE.md index 4eea0fcb..c279e8ba 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -5,6 +5,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co ## Commands ### Development + - `pnpm test` - Run tests using Vitest - `pnpm run build` - Build the TypeScript project - `pnpm run clean` - Clean build artifacts @@ -12,6 +13,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co - `pnpm run eslint:fix` - Run ESLint with auto-fix ### Package Management + - Uses pnpm as package manager (required, enforced by preinstall hook) - `pnpm install` - Install dependencies @@ -22,10 +24,12 @@ This is a TypeScript implementation of PHPDoc parser inspired by PHPStan's phpdo ### Core Components **Lexical Analysis (`src/phpdoc-parser/lexer/`)** + - `lexer.ts` - Tokenizes PHPDoc strings using regex patterns - Handles 20+ token types (identifiers, types, operators, brackets, etc.) **Parsing (`src/phpdoc-parser/parser/`)** + - `php-doc-parser.ts` - Main parser that converts tokens to AST nodes - `type-parser.ts` - Handles type parsing (generics, unions, intersections) - `const-expr-parser.ts` - Parses constant expressions @@ -33,17 +37,20 @@ This is a TypeScript implementation of PHPDoc parser inspired by PHPStan's phpdo - `string-unescaper.ts` - String literal processing **AST Nodes (`src/phpdoc-parser/ast/`)** + - Base interfaces: `node.ts`, `base-node.ts` - **php-doc/**: PHPDoc-specific nodes (tags, text, parameters, etc.) - **type/**: Type system nodes (unions, intersections, generics, arrays) - **const-expr/**: Constant expression nodes (strings, numbers, arrays) **Printing (`src/phpdoc-parser/printer/`)** + - `printer.ts` - Converts AST back to formatted PHPDoc - `differ.ts` - Format-preserving printing with diff tracking - Supports both clean formatting and original format preservation **Transpilation (`src/phpdoc-parser/transpiler/`)** + - `php-doc-to-typescript-type-transpiler.ts` - Converts PHPDoc types to TypeScript ### Key Patterns @@ -66,4 +73,4 @@ This is a TypeScript implementation of PHPDoc parser inspired by PHPStan's phpdo - `src/index.ts` - Main entry point exporting all public APIs - `tests/` - Test files organized by component (lexer, parser, printer, transpiler) -- TypeScript build configuration in `tsconfig.build.json` \ No newline at end of file +- TypeScript build configuration in `tsconfig.build.json`