diff --git a/.github/workflows/ci-typescript.yaml b/.github/workflows/ci-typescript.yaml index 38fbc2d3..ec27ab84 100644 --- a/.github/workflows/ci-typescript.yaml +++ b/.github/workflows/ci-typescript.yaml @@ -13,87 +13,50 @@ jobs: - name: Checkout source uses: actions/checkout@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + run_install: false + - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: "latest" + cache: "pnpm" registry-url: "https://registry.npmjs.org/" scope: "@blueyerobotics" - - name: Create tsconfig - run: | - cd protobuf_definitions - echo '{ - "compilerOptions": { - "target": "ES2020", - "module": "CommonJS", - "declaration": true, - "outDir": "dist", - "strict": true, - "esModuleInterop": true - }, - "include": ["./**/*.ts"] - }' > tsconfig.json - - - name: Create package - run: | - cd protobuf_definitions - SHORT_SHA=${GITHUB_SHA::8} - echo '{ - "name": "@blueyerobotics/protocol-definitions", - "version": "3.2.0-'${SHORT_SHA}'", - "license": "LGPL-3.0-only", - "description": "TypeScript definitions for Blueye Robotics protocols", - "repository": { - "type": "git", - "url": "https://github.com/BluEye-Robotics/ProtocolDefinitions.git" - }, - "main": "dist/index.js", - "types": "dist/index.d.ts", - "files": ["dist"], - "scripts": { - "build": "tsc" - }, - "dependencies": { - "@bufbuild/protobuf": "^2.5.2" - }, - "devDependencies": { - "ts-proto": "^2.7.5", - "typescript": "^5.8.3" - } - }' > package.json - - name: Install dependencies run: | sudo apt-get update sudo apt-get install -y protobuf-compiler - cd protobuf_definitions - npm install + pnpm install - name: Generate run: | - cd protobuf_definitions mkdir -p ./out/ && - protoc *.proto --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./out \ + protoc protobuf_definitions/*.proto \ + --plugin=./node_modules/.bin/protoc-gen-ts_proto \ + --ts_proto_out=./out \ --ts_proto_opt=outputIndex=true \ --ts_proto_opt=globalThisPolyfill=true \ --ts_proto_opt=useExactTypes=false - name: Compile - run: | - cd protobuf_definitions - npm run build + run: pnpm run build - name: Publish to npm run: | - cp README.npm.md protobuf_definitions/README.md - cd protobuf_definitions - npm publish --access public --tag latest + cp README.npm.md README.md + VERSION=$(pnpm pkg get version | tr -d '"') + SHORT_SHA=${GITHUB_SHA::8} + pnpm version --no-git-tag-version "${VERSION}-${SHORT_SHA}" + pnpm publish --access public --tag latest env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Check npm pack contents run: | - cd protobuf_definitions - npm pack + pnpm pack tar -tzf *.tgz diff --git a/.gitignore b/.gitignore index c8130ee7..a4b51f5d 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ out build build_imx build_* +node_modules # Rider directories -.idea \ No newline at end of file +.idea diff --git a/package.json b/package.json new file mode 100644 index 00000000..aa763b88 --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "@blueyerobotics/protocol-definitions", + "version": "3.2.0", + "license": "LGPL-3.0-only", + "description": "TypeScript definitions for Blueye Robotics protocols", + "repository": { + "type": "git", + "url": "https://github.com/BluEye-Robotics/ProtocolDefinitions.git" + }, + "main": "dist/index.js", + "types": "dist/index.d.ts", + "files": [ + "dist" + ], + "scripts": { + "build": "tsc" + }, + "dependencies": { + "@bufbuild/protobuf": "^2.5.2" + }, + "devDependencies": { + "ts-proto": "^2.7.5", + "typescript": "^5.8.3" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 00000000..8947f86a --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,81 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + '@bufbuild/protobuf': + specifier: ^2.5.2 + version: 2.8.0 + devDependencies: + ts-proto: + specifier: ^2.7.5 + version: 2.7.7 + typescript: + specifier: ^5.8.3 + version: 5.9.2 + +packages: + + '@bufbuild/protobuf@2.8.0': + resolution: {integrity: sha512-r1/0w5C9dkbcdjyxY8ZHsC5AOWg4Pnzhm2zu7LO4UHSounp2tMm6Y+oioV9zlGbLveE7YaWRDUk48WLxRDgoqg==} + + case-anything@2.1.13: + resolution: {integrity: sha512-zlOQ80VrQ2Ue+ymH5OuM/DlDq64mEm+B9UTdHULv5osUMD6HalNTblf2b1u/m6QecjsnOkBpqVZ+XPwIVsy7Ng==} + engines: {node: '>=12.13'} + + detect-libc@1.0.3: + resolution: {integrity: sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==} + engines: {node: '>=0.10'} + hasBin: true + + dprint-node@1.0.8: + resolution: {integrity: sha512-iVKnUtYfGrYcW1ZAlfR/F59cUVL8QIhWoBJoSjkkdua/dkWIgjZfiLMeTjiB06X0ZLkQ0M2C1VbUj/CxkIf1zg==} + + ts-poet@6.12.0: + resolution: {integrity: sha512-xo+iRNMWqyvXpFTaOAvLPA5QAWO6TZrSUs5s4Odaya3epqofBu/fMLHEWl8jPmjhA0s9sgj9sNvF1BmaQlmQkA==} + + ts-proto-descriptors@2.0.0: + resolution: {integrity: sha512-wHcTH3xIv11jxgkX5OyCSFfw27agpInAd6yh89hKG6zqIXnjW9SYqSER2CVQxdPj4czeOhGagNvZBEbJPy7qkw==} + + ts-proto@2.7.7: + resolution: {integrity: sha512-/OfN9/Yriji2bbpOysZ/Jzc96isOKz+eBTJEcKaIZ0PR6x1TNgVm4Lz0zfbo+J0jwFO7fJjJyssefBPQ0o1V9A==} + hasBin: true + + typescript@5.9.2: + resolution: {integrity: sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==} + engines: {node: '>=14.17'} + hasBin: true + +snapshots: + + '@bufbuild/protobuf@2.8.0': {} + + case-anything@2.1.13: {} + + detect-libc@1.0.3: {} + + dprint-node@1.0.8: + dependencies: + detect-libc: 1.0.3 + + ts-poet@6.12.0: + dependencies: + dprint-node: 1.0.8 + + ts-proto-descriptors@2.0.0: + dependencies: + '@bufbuild/protobuf': 2.8.0 + + ts-proto@2.7.7: + dependencies: + '@bufbuild/protobuf': 2.8.0 + case-anything: 2.1.13 + ts-poet: 6.12.0 + ts-proto-descriptors: 2.0.0 + + typescript@5.9.2: {} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..fc30754e --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "CommonJS", + "declaration": true, + "outDir": "dist", + "strict": true, + "esModuleInterop": true + }, + "include": ["./**/*.ts"] +}