Skip to content

Commit 10640df

Browse files
authored
🐛 harmonize OS names across clients (#330)
1 parent 85fe1f8 commit 10640df

File tree

9 files changed

+75
-39
lines changed

9 files changed

+75
-39
lines changed

.github/workflows/publish.yml renamed to .github/workflows/_publish-code.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#
22
# Publish releases to NPM
33
#
4-
name: Publish
4+
name: Publish Code
55

66
on:
7-
release:
8-
types: [ published ]
7+
workflow_call:
8+
workflow_dispatch:
99

1010
jobs:
1111
publish:

.github/workflows/docs.yml renamed to .github/workflows/_publish-docs.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
name: Documentation
1+
#
2+
# Publish Documentation to GitHub pages.
3+
#
4+
name: Publish Documentation
25

36
on:
4-
release:
5-
types: [ published ]
6-
7-
# Allows running this workflow manually from the Actions tab
7+
workflow_call:
88
workflow_dispatch:
99

1010
jobs:
11-
publish-docs:
12-
name: Publish Docs
11+
documentation:
12+
name: Publish Documentation
1313
runs-on: ubuntu-latest
1414

1515
steps:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Publish Guide to readme.com
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
jobs:
8+
sync:
9+
uses: mindee/client-lib-actions/.github/workflows/publish-guide.yml@main
10+
secrets: inherit
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Publish Release
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
7+
jobs:
8+
publish_docs:
9+
uses: mindee/mindee-api-nodejs/.github/workflows/_publish-docs.yml@main
10+
secrets: inherit
11+
publish_guide:
12+
uses: mindee/mindee-api-nodejs/.github/workflows/_publish-guide.yml@main
13+
needs: publish_docs
14+
secrets: inherit
15+
publish_code:
16+
uses: mindee/mindee-api-nodejs/.github/workflows/_publish-code.yml@main
17+
secrets: inherit
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Push Main Branch
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
tag:
10+
uses: mindee/client-lib-actions/.github/workflows/tag-version.yml@main

.github/workflows/sync-readme.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/test-integration.yml renamed to .github/workflows/test-integrations.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ on:
66
jobs:
77
run-tests:
88
name: Run Integration Tests
9-
runs-on: ubuntu-latest
9+
timeout-minutes: 30
1010
strategy:
11+
max-parallel: 4
1112
matrix:
13+
os:
14+
- "ubuntu-latest"
15+
- "windows-latest"
16+
- "macos-latest"
1217
node-version:
1318
- "18"
14-
- "20"
1519
- "22"
20+
runs-on: ${{ matrix.os }}
1621

1722
steps:
1823
- name: Check out Git repository

.github/workflows/test.yml renamed to .github/workflows/test-units.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ on:
66
jobs:
77
run-tests:
88
name: Run Tests
9-
runs-on: ubuntu-latest
109
strategy:
10+
max-parallel: 4
1111
matrix:
12+
os:
13+
- "ubuntu-latest"
1214
node-version:
1315
- "18"
1416
- "20"
1517
- "22"
18+
runs-on: ${{ matrix.os }}
1619

1720
steps:
1821
- name: Check out Git repository

src/http/apiSettings.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ interface MindeeApiConstructorProps {
1313
apiKey: string;
1414
}
1515

16-
const USER_AGENT: string = `mindee-api-nodejs@v${sdkVersion} nodejs-${
17-
process.version
18-
} ${os.type().toLowerCase()}`;
19-
2016
export class ApiSettings {
2117
apiKey: string;
2218
baseHeaders: Record<string, string>;
@@ -38,13 +34,29 @@ export class ApiSettings {
3834
);
3935
}
4036
this.baseHeaders = {
41-
"User-Agent": USER_AGENT,
37+
"User-Agent": this.getUserAgent(),
4238
Authorization: `Token ${this.apiKey}`,
4339
};
4440
this.hostname = this.hostnameFromEnv();
4541
this.timeout = process.env.MINDEE_REQUEST_TIMEOUT ? parseInt(process.env.MINDEE_REQUEST_TIMEOUT) : TIMEOUT_DEFAULT;
4642
}
4743

44+
protected getUserAgent(): string {
45+
let platform = os.type().toLowerCase();
46+
if (platform.includes("darwin")) {
47+
platform = "macos";
48+
}
49+
else if (platform.includes("window")) {
50+
platform = "windows";
51+
}
52+
else if (platform.includes("bsd")) {
53+
platform = "bsd";
54+
}
55+
return `mindee-api-nodejs@v${sdkVersion} nodejs-${
56+
process.version
57+
} ${platform}`;
58+
}
59+
4860
protected apiKeyFromEnv(): string {
4961
const envVarValue = process.env[API_KEY_ENVVAR_NAME];
5062
if (envVarValue) {

0 commit comments

Comments
 (0)