Skip to content

Commit c65ff7b

Browse files
authored
Merge pull request #918 from syucream/fix/use-npm-package
Finally use published API client package; goodbye repository-owned client!
2 parents 3d28a8a + b9815db commit c65ff7b

File tree

167 files changed

+195
-13650
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+195
-13650
lines changed

.babelrc

-11
This file was deleted.

.github/workflows/build-frontend.yml

+21
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,58 @@ on:
1313
jobs:
1414
lint:
1515
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: read
1619
steps:
1720
- uses: actions/checkout@v3
1821
- uses: actions/setup-node@v3
1922
with:
2023
node-version: 16
24+
registry-url: https://npm.pkg.github.com/
25+
scope: '@dmm-com'
2126
cache: 'npm'
2227
- name: install dependencies
2328
run: npm ci
29+
env:
30+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
2431
- name: lint
2532
run: npm run lint
2633
build:
2734
runs-on: ubuntu-latest
35+
permissions:
36+
contents: read
37+
packages: read
2838
steps:
2939
- uses: actions/checkout@v3
3040
- uses: actions/setup-node@v3
3141
with:
3242
node-version: 16
43+
registry-url: https://npm.pkg.github.com/
44+
scope: '@dmm-com'
3345
cache: 'npm'
3446
- name: install dependencies
3547
run: npm ci
48+
env:
49+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
3650
- name: build
3751
run: npm run build:development
3852
test:
3953
runs-on: ubuntu-latest
54+
permissions:
55+
contents: read
56+
packages: read
4057
steps:
4158
- uses: actions/checkout@v3
4259
- uses: actions/setup-node@v3
4360
with:
4461
node-version: 16
62+
registry-url: https://npm.pkg.github.com/
63+
scope: '@dmm-com'
4564
cache: 'npm'
4665
- name: install dependencies
4766
run: npm ci
67+
env:
68+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
4869
- name: test
4970
run: npm run test

.github/workflows/release-apiv2-client.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ on:
66
pull_request_target:
77
types: [labeled]
88
paths:
9-
- '**/api_v2/**/*.py'
10-
- 'apiclient/typescript-fetch/package.json'
11-
- '.github/workflows/release-apiv2-client.yml'
9+
- "**/api_v2/**/*.py"
10+
- "apiclient/typescript-fetch/package.json"
11+
- ".github/workflows/release-apiv2-client.yml"
1212

1313
jobs:
1414
release:
@@ -29,7 +29,7 @@ jobs:
2929
sudo apt-get install libldap2-dev libsasl2-dev libxmlsec1-dev libmysqlclient-dev pkg-config
3030
- uses: actions/setup-python@v4
3131
with:
32-
python-version: '3.10'
32+
python-version: "3.10"
3333
- name: venv
3434
run: |
3535
python3 -m venv virtualenv
@@ -46,13 +46,13 @@ jobs:
4646
with:
4747
node-version: 16
4848
registry-url: https://npm.pkg.github.com/
49-
scope: '@dmm-com'
49+
scope: "@dmm-com"
5050
- name: install dependencies
5151
run: npm ci
5252
env:
5353
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
5454
- name: generate client
55-
run: npm run generate:client:new
55+
run: npm run generate:client
5656
- run: npm publish
5757
env:
5858
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -62,7 +62,7 @@ jobs:
6262
id: fc
6363
with:
6464
issue-number: ${{ github.event.pull_request.number }}
65-
comment-author: 'github-actions[bot]'
65+
comment-author: "github-actions[bot]"
6666
body-includes: "<!-- release-apiv2-client-notification -->"
6767
- name: Create or update comment
6868
uses: peter-evans/create-or-update-comment@v3

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ static/js/ui.js*
177177
airone/settings.py
178178

179179
# Auto-generated APIv2 client implementations
180+
frontend/src/apiclient/autogenerated/
180181
apiclient/typescript-fetch/src/autogenerated/
181182

182183
# helm

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@dmm-com:registry=https://npm.pkg.github.com

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,29 @@ user@hostname:~/airone$ cp -pi ./frontend/src/App.tsx ./frontend/src/customview/
298298
user@hostname:~/airone$ npm run build:custom
299299
```
300300

301+
### API V2 client
302+
303+
Prepare to install API client npm package published on GitHub Packages.
304+
`TOKEN` is a your GitHub PAT. Issue your PAT with checking [this doc](https://docs.github.com/ja/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#github-packages-%E3%81%B8%E3%81%AE%E8%AA%8D%E8%A8%BC%E3%82%92%E8%A1%8C%E3%81%86).
305+
Then, you just perform `npm install` as usual.
306+
307+
```
308+
$ cat > .npmrc
309+
//npm.pkg.github.com/:_authToken=TOKEN
310+
```
311+
312+
You can refer your local API client code before publishing it to GitHub Packages with following command.
313+
314+
```shell
315+
# generate the latest API client code on your local env
316+
$ npm run generate:client
317+
318+
# refer the latest code temporarily
319+
$ npm run link:client
320+
```
321+
322+
If you modify something in API client code, you need to publish it with the package release GitHub Actions workflow. It will be triggered by labeling `release-apiv2-client` to the pull request by repository owners.
323+
301324
## Auto-format
302325

303326
```

apiclient/typescript-fetch/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dmm-com/airone-apiclient-typescript-fetch",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "AirOne APIv2 client in TypeScript",
55
"main": "src/autogenerated/index.ts",
66
"scripts": {

babel.config.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
"presets": [
3+
"@babel/preset-react",
4+
[
5+
"@babel/preset-env", { "targets": { "node": "current" } }
6+
]
7+
],
8+
"plugins": [
9+
"transform-class-properties"
10+
]
11+
};

frontend/src/apiclient/autogenerated/.gitkeep

Whitespace-only changes.

frontend/src/apiclient/autogenerated/.openapi-generator-ignore

-23
This file was deleted.

frontend/src/apiclient/autogenerated/.openapi-generator/FILES

-90
This file was deleted.

frontend/src/apiclient/autogenerated/.openapi-generator/VERSION

-1
This file was deleted.

0 commit comments

Comments
 (0)