From 1246e01b18bc9f55737014c9ab0f1eec691631a1 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 5 Dec 2022 17:12:04 -0800 Subject: [PATCH 1/2] docs: fix the document generation --- package.json | 16 +++++++++++----- pnpm-lock.yaml | 19 +++++-------------- tsconfig-build.json | 9 --------- tsconfig.docs.json | 11 +++++++++++ typedoc.json | 22 ++++++++++++++++++++++ 5 files changed, 49 insertions(+), 28 deletions(-) delete mode 100644 tsconfig-build.json create mode 100644 tsconfig.docs.json create mode 100644 typedoc.json diff --git a/package.json b/package.json index a2f59c56..0b2693e8 100644 --- a/package.json +++ b/package.json @@ -18,10 +18,10 @@ }, "dependencies": { "@aminya/node-gyp-build": "4.5.0-aminya.4", + "cross-env": "^7.0.3", "node-addon-api": "^5.0.0", "shelljs": "^0.8.5", - "shx": "^0.3.4", - "cross-env": "^7.0.3" + "shx": "^0.3.4" }, "devDependencies": { "@gnd/typedoc": "^0.15.0-0", @@ -52,6 +52,11 @@ "weak-napi": "^2.0.2", "which": "^3.0.0" }, + "pnpm": { + "overrides": { + "typescript": "~4.9.3" + } + }, "engines": { "node": ">= 10.2" }, @@ -72,10 +77,11 @@ "install": "(shx test -f ./script/build.js || run-s build.js) && cross-env npm_config_build_from_source=true node-gyp-build", "clean": "shx rm -rf ./build ./lib/ ./prebuilds ./script/*.js ./script/*.js.map ./script/*.d.ts ./script/*.tsbuildinfo", "clean.temp": "shx rm -rf ./tmp && shx mkdir -p ./tmp && shx touch ./tmp/.gitkeep", - "build.library": "tsc -p ./src/tsconfig.json && downlevel-dts ./lib ./lib/ts3.7 --to=3.7", + "build.library.compat": "shx rm -rf ./lib/ts3.7 && downlevel-dts ./lib ./lib/ts3.7 --to=3.7", + "build.library": "tsc -p ./src/tsconfig.json && run-s build.library.compat", "build.script": "tsc -p ./script/tsconfig.json", "build.js": "run-p build.script build.library", - "build.doc": "typedoc --out docs --name zeromq.js --excludeProtected --excludePrivate --excludeNotExported --excludeExternals --externalPattern 'src/+(draft|native|compat).ts' --tsconfig tsconfig-build.json --mode file", + "build.doc": "typedoc --options ./typedoc.json --tsconfig ./tsconfig.docs.json", "prebuild": "run-s build.js && node ./script/prebuild.js", "build.native": "node-gyp configure --release && node-gyp build --release", "build.native.debug": "cross-env CMAKE_BUILD_TYPE=Debug node-gyp configure --debug && cross-env CMAKE_BUILD_TYPE=Debug node-gyp build --debug", @@ -89,7 +95,7 @@ "lint": "run-p lint.eslint lint.clang-format", "lint-test": "run-s lint-test.eslint", "bench": "node --expose-gc test/bench", - "prepublishOnly": "shx rm -rf ./lib && pnpm run build.js" + "prepublishOnly": "pnpm run build.js" }, "keywords": [ "zeromq", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fb49f8b3..eb55d24d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,5 +1,8 @@ lockfileVersion: 5.4 +overrides: + typescript: ~4.9.3 + specifiers: '@aminya/node-gyp-build': 4.5.0-aminya.4 '@gnd/typedoc': ^0.15.0-0 @@ -382,7 +385,7 @@ packages: progress: 2.0.3 shelljs: 0.8.5 typedoc-default-themes: 0.6.3 - typescript: 3.6.5 + typescript: 4.9.3 dev: true /@humanwhocodes/config-array/0.11.7: @@ -1647,7 +1650,7 @@ packages: dependencies: semver: 7.3.8 shelljs: 0.8.5 - typescript: 5.0.0-dev.20221205 + typescript: 4.9.3 dev: true /duplexer3/0.1.5: @@ -4566,24 +4569,12 @@ packages: underscore: 1.13.6 dev: true - /typescript/3.6.5: - resolution: {integrity: sha512-BEjlc0Z06ORZKbtcxGrIvvwYs5hAnuo6TKdNFL55frVDlB+na3z5bsLhFaIxmT+dPWgBIjMo6aNnTOgHHmHgiQ==} - engines: {node: '>=4.2.0'} - hasBin: true - dev: true - /typescript/4.9.3: resolution: {integrity: sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==} engines: {node: '>=4.2.0'} hasBin: true dev: true - /typescript/5.0.0-dev.20221205: - resolution: {integrity: sha512-afHkcfhaQqUk+Hjn+lUKtMqMttizIy5K2r75cz8l7/K+m0k6Yx9IoHRC5v8cjxB77ub2COdbr+0xsNodB7q6dg==} - engines: {node: '>=4.2.0'} - hasBin: true - dev: true - /uglify-js/3.17.4: resolution: {integrity: sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==} engines: {node: '>=0.8.0'} diff --git a/tsconfig-build.json b/tsconfig-build.json deleted file mode 100644 index a9fead6c..00000000 --- a/tsconfig-build.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src"], - "compilerOptions": { - "outDir": "lib", - "noUnusedLocals": true, - "noUnusedParameters": true - } -} diff --git a/tsconfig.docs.json b/tsconfig.docs.json new file mode 100644 index 00000000..7e209067 --- /dev/null +++ b/tsconfig.docs.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "incremental": false, + "paths": { + "zeromq": [ + "./src/index.ts" + ] + } + } +} diff --git a/typedoc.json b/typedoc.json new file mode 100644 index 00000000..58fc9b57 --- /dev/null +++ b/typedoc.json @@ -0,0 +1,22 @@ +{ + "$schema": "https://typedoc.org/schema.json", + "name": "zeromq.js", + "entryPoints": [ + "./src/index.ts" + ], + "tsconfig": " ./tsconfig.docs.json", + "out": "docs", + "excludePrivate": true, + "excludeNotExported": true, + "excludeExternals": true, + "exclude": [ + "script/**/*", + "test/**/*", + "examples/**/*", + "src/+(draft|native|compat).ts", + "src/errors.ts", + "src/util.ts" + ], + "pretty": false, + "githubPages": true +} From e2a0d4e335af136560b66359c119940c19ccf98c Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 5 Dec 2022 18:14:27 -0800 Subject: [PATCH 2/2] ci: automate generating and deploying documentation --- .github/workflows/CI.yml | 72 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 727c4e92..7cafdcda 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -81,9 +81,9 @@ jobs: path: | ./node_modules/ ./build/ - key: "cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch }}-ZMQ_DRAFT:${{ matrix.zmq_draft }}-ZMQ_VERSION:${{ matrix.zmq_version }}-Node:${{ matrix.node_version }}-${{ hashFiles('./package.json') }}" + key: "cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch }}-ZMQ_DRAFT:${{ matrix.zmq_draft }}-Node:${{ matrix.node_version }}-${{ hashFiles('./package.json') }}" restore-keys: | - "cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch }}-ZMQ_DRAFT:${{ matrix.zmq_draft }}-ZMQ_VERSION:${{ matrix.zmq_version }}-Node:${{ matrix.node_version }}-" + "cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch }}-ZMQ_DRAFT:${{ matrix.zmq_draft }}-Node:${{ matrix.node_version }}-" - name: Setup Cpp if: ${{ !matrix.docker }} @@ -160,3 +160,71 @@ jobs: run: | pnpm run clean pnpm run test + + Docs: + if: "startsWith(github.ref, 'refs/tags/') && !contains(github.event.head_commit.message, '[skip ci]')" + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + os: + - ubuntu-22.04 + node_version: + - 18 + node_arch: + - x64 + cpp_arch: + - x64 + ARCH: + - x64 + zmq_draft: + - false + env: + ZMQ_DRAFT: ${{ matrix.zmq_draft }} + ZMQ_SHARED: false + ARCH: ${{ matrix.ARCH }} + + steps: + - uses: actions/checkout@v3 + + - name: Cache + uses: actions/cache@v3 + with: + path: | + ./node_modules/ + ./build/ + key: "cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch }}-ZMQ_DRAFT:${{ matrix.zmq_draft }}-Node:${{ matrix.node_version }}-${{ hashFiles('./package.json') }}" + restore-keys: | + "cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch }}-ZMQ_DRAFT:${{ matrix.zmq_draft }}-Node:${{ matrix.node_version }}-" + + - name: Setup Cpp + uses: aminya/setup-cpp@v1 + with: + cmake: true + architecture: ${{ matrix.cpp_arch }} + + - uses: pnpm/action-setup@v2.2.4 + with: + version: 7 + + - name: Install Node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node_version }} + architecture: ${{ matrix.node_arch }} + cache: "pnpm" + + - name: Build Documentation + if: "${{ contains(matrix.os, 'ubuntu') && !matrix.docker }}" + run: | + pnpm install + pnpm run build.doc + + - name: Deploy Documentation + if: "${{ contains(matrix.os, 'ubuntu') && !matrix.docker }}" + uses: Cecilapp/GitHub-Pages-deploy@v3 + with: + build_dir: docs + branch: gh-pages + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}