Skip to content

Commit

Permalink
feat(deps): use ApiDOM npmjs.com npm packages (#2861)
Browse files Browse the repository at this point in the history
Refs #2860
  • Loading branch information
char0n authored Mar 1, 2023
1 parent f9c582a commit 1360993
Show file tree
Hide file tree
Showing 7 changed files with 414 additions and 510 deletions.
15 changes: 2 additions & 13 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: https://npm.pkg.github.com/
scope: "@swagger-api"
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v3
Expand All @@ -34,8 +32,6 @@ jobs:
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Lint commit message
if: github.ref != 'refs/heads/main' && github.actor != 'dependabot[bot]'
run: git log -1 --pretty=format:"%s" | npx commitlint
Expand Down Expand Up @@ -65,9 +61,6 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 12.20.0
registry-url: https://npm.pkg.github.com/
scope: "@swagger-api"

- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v3
Expand All @@ -78,8 +71,6 @@ jobs:
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Download commonjs build artifacts
uses: actions/download-artifact@v3
Expand All @@ -93,16 +84,14 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 14.x
registry-url: https://npm.pkg.github.com/
scope: "@swagger-api"

- name: Run commonjs build artifacts on Node.js 14.x
run: node -p "require('./commonjs')"

- name: Use Node 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: https://npm.pkg.github.com/
scope: "@swagger-api"

- name: Run commonjs build artifacts on Node.js 16.x
run: node -p "require('./commonjs')"
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ jobs:
with:
fetch-depth: 0
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://npm.pkg.github.com/
scope: "@swagger-api"

- name: Install dependencies
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Semantic Release
id: semantic
uses: cycjimmy/[email protected]
Expand All @@ -34,6 +33,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Release published
if: steps.semantic.outputs.new_release_published == 'true'
run: |
Expand Down
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

30 changes: 1 addition & 29 deletions docs/development/setting-up.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,7 @@ If you use [nvm](https://github.com/nvm-sh/nvm), running following command insid
$ nvm use
```

This repository is using npm packages from https://www.npmjs.com/ and [GitHub packages registry](https://docs.github.com/en/packages/learn-github-packages/introduction-to-github-packages).
To successfully install npm packages that SwaggerEditor requires, you need to [Authenticate to GitHub Packages](https://docs.github.com/en/packages/learn-github-packages/introduction-to-github-packages).

You can authenticate to GitHub Packages with npm by either editing your per-user *~/.npmrc*
file to include your personal access token (classic) or by logging in to npm on the command line using your username and personal access token.

To authenticate by adding your personal access token (classic) to your *~/.npmrc* file,
edit the *~/.npmrc* file for your project to include the following line,
replacing TOKEN with your personal access token. Create a new *~/.npmrc* file if one doesn't exist.
You can find more information about authenticating to GitHub Packages in [GitHub documentation](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-to-github-packages).

```
//npm.pkg.github.com/:_authToken=TOKEN
```


Alternatively, to authenticate by logging in to npm, use the `npm login` command,
replacing USERNAME with your GitHub username, TOKEN with your personal access token (classic),
and PUBLIC-EMAIL-ADDRESS with your email address.

```sh
$ npm login --scope=@swagger-api --registry=https://npm.pkg.github.com

> Username: USERNAME
> Password: TOKEN
> Email: PUBLIC-EMAIL-ADDRESS
```

### Steps
#### Setup teps

1. `git clone https://github.com/swagger-api/swagger-js.git`
2. `cd swagger-js`
Expand Down
29 changes: 29 additions & 0 deletions docs/usage/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,35 @@ The npm package contains transpiled and minified ES5 compatible code.
$ npm install swagger-client
```

**Increasing installation speed:**

`swagger-client` integrates with [ApiDOM](https://github.com/swagger-api/apidom) and use it
as a direct dependency. Some transitive dependencies of ApiDOM are [optional](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#optionaldependencies),
which means we can use [override package.json field](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides)
to speed up the installation:

```json
"overrides": {
"@swagger-api/apidom-reference": {
"@swagger-api/apidom-ns-asyncapi-2": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-api-design-systems-json": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-api-design-systems-yaml": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-asyncapi-json-2": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-asyncapi-yaml-2": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-json": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-openapi-json-3-0": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-openapi-json-3-1": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-openapi-yaml-3-0": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-openapi-yaml-3-1": "npm:[email protected]",
"@swagger-api/apidom-parser-adapter-yaml-1-2": "npm:[email protected]"
}
}
```

> NOTE 1: Above override uses [empty npm package called "-"](https://www.npmjs.com/package/-) to override optional ApiDOM transitive dependencies.
> NOTE 2: When ApiDOM optional dependencies fail to install, you can safely ignore it as `swagger-client` can work without these optional dependencies.
After installed successfully:

[ES6 imports](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import)
Expand Down
Loading

0 comments on commit 1360993

Please sign in to comment.