From 156f8b6a041f604c9933d4a709282d894823981b Mon Sep 17 00:00:00 2001 From: LexLuengas Date: Fri, 9 Dec 2022 17:12:47 +0100 Subject: [PATCH] Publish openapi-mock-server independently --- .dockerignore | 3 +- .github/workflows/nodejs.yml | 6 +-- .../publish-npm-package-mock-server.yml | 47 +++++++++++++++++++ mock-server/package.json | 16 +++++-- package.json | 2 +- 5 files changed, 63 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/publish-npm-package-mock-server.yml diff --git a/.dockerignore b/.dockerignore index ca421fc2..5a24116a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,5 @@ node_modules build -mock-server/node_modules -mock-server/build +mock-server .idea .vscode diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 98f03fe1..4095e3e4 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -34,11 +34,7 @@ jobs: with: node-version: ${{ matrix.node-version }} - - name: Install dependencies & build (mock) - working-directory: ./mock-server - run: npm ci - - - name: Install dependencies & build (proxy) + - name: Install dependencies & build run: npm ci - name: Test diff --git a/.github/workflows/publish-npm-package-mock-server.yml b/.github/workflows/publish-npm-package-mock-server.yml new file mode 100644 index 00000000..bc2d4d82 --- /dev/null +++ b/.github/workflows/publish-npm-package-mock-server.yml @@ -0,0 +1,47 @@ +name: Publish openapi-mock-server Node.js package + +on: + workflow_dispatch: + +env: + NODE_VERSION: '10.x' + +jobs: + publish-to-npmjs: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./mock-server + steps: + - uses: actions/checkout@v3 + - name: Set up publishing to npmjs.com + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + registry-url: 'https://registry.npmjs.org' + - run: npm ci + - run: npm run compile + - run: npm publish --access=public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + publish-to-github-packages: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./mock-server + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v3 + - name: Set up publishing to GitHub Packages + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + registry-url: 'https://npm.pkg.github.com' + scope: '@exxeta' + - run: npm ci + - run: npm run compile + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/mock-server/package.json b/mock-server/package.json index 783410a2..224fb24f 100755 --- a/mock-server/package.json +++ b/mock-server/package.json @@ -1,12 +1,22 @@ { - "name": "openapi-cop-mock-server", + "name": "@exxeta/openapi-cop-mock-server", "version": "1.0.0", - "description": "Mock server for use together with the openapi-cop proxy server", + "description": "Mock server used to test openapi-cop proxy server.", "license": "MIT", "author": "Alexis Luengas", - "private": true, + "repository": { + "type": "git", + "url": "https://github.com/EXXETA/openapi-cop.git" + }, + "engines": { + "node": "^10 || ^12" + }, "main": "./build/src/app", "bin": "./build/src/cli.js", + "types": "./build/src/app.d.ts", + "files": [ + "build/" + ], "scripts": { "postinstall": "npm run compile", "check": "gts check", diff --git a/package.json b/package.json index 5dc59da4..14b634e5 100755 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "find-process": "1.4.7", "gts": "3.1.1", "mocha": "9.2.2", - "openapi-cop-mock-server": "file:./mock-server", + "openapi-cop-mock-server": "1.0.0", "typescript": "4.0.5" } }