From a88fb113ba6eb85e8c925341d21ce1030e856eb4 Mon Sep 17 00:00:00 2001 From: Maifee Ul Asad Date: Sun, 25 Sep 2022 02:07:51 +0600 Subject: [PATCH 01/13] major feature: bump up the version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3770f98..45581eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "os-check", - "version": "2.1.0", + "version": "2.2.0", "description": "Check OS of the host system", "main": "index.ts", "scripts": { From e2dd430f2ff0081d4f296337566e199882f99aef Mon Sep 17 00:00:00 2001 From: Maifee Ul Asad Date: Sun, 25 Sep 2022 13:19:55 +0600 Subject: [PATCH 02/13] export + bump up version --- index.ts | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/index.ts b/index.ts index d8baba1..cf8daab 100644 --- a/index.ts +++ b/index.ts @@ -33,3 +33,5 @@ const osCheck = (): OsType => { } return OsType.Others; }; + +export { osCheck }; diff --git a/package.json b/package.json index 45581eb..0321fa3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "os-check", - "version": "2.2.0", + "version": "2.3.0", "description": "Check OS of the host system", "main": "index.ts", "scripts": { From 24cd622983f808398cb2ccdf3c91b74877619822 Mon Sep 17 00:00:00 2001 From: Maifee Ul Asad Date: Sun, 25 Sep 2022 13:29:37 +0600 Subject: [PATCH 03/13] enum values + export enum --- index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/index.ts b/index.ts index cf8daab..b03a41a 100644 --- a/index.ts +++ b/index.ts @@ -1,10 +1,10 @@ enum OsType { - MacOS, - iOS, - Windows, - Android, - Linux, - Others, + MacOS = "MacOS", + iOS = "iOS", + Windows = "Windows", + Android = "Android", + Linux = "Linux", + Others = "Others OS", } const osCheck = (): OsType => { @@ -34,4 +34,4 @@ const osCheck = (): OsType => { return OsType.Others; }; -export { osCheck }; +export { osCheck, OsType }; From c23525636ffb1c0aac8884e54a9fb20c8a4bc015 Mon Sep 17 00:00:00 2001 From: Maifee Ul Asad Date: Sun, 25 Sep 2022 13:31:16 +0600 Subject: [PATCH 04/13] version: bump to 2.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0321fa3..e939161 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "os-check", - "version": "2.3.0", + "version": "2.4.0", "description": "Check OS of the host system", "main": "index.ts", "scripts": { From 7e6900040e5e8028daf204a999e7afb0f45c9982 Mon Sep 17 00:00:00 2001 From: Maifee Ul Asad <29339330+maifeeulasad@users.noreply.github.com> Date: Sun, 25 Sep 2022 13:39:03 +0600 Subject: [PATCH 05/13] added doc usage --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 084cce8..d1efd50 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,32 @@ # os-check -here : https://www.npmjs.com/package/os-check +NPM : https://www.npmjs.com/package/os-check ``` npm install os-check yarn add os-check ``` + +## Code + - codesandbox: https://codesandbox.io/s/os-check-example-hro7y6?file=/src/App.tsx + - Usage: + ``` + import React, { useEffect } from "react"; + +import { osCheck, OsType } from "os-check"; + +const App = () => { + useEffect(() => { + // alert(osCheck()) + }, []); + return ( +
+

{osCheck()}

+

{osCheck() === OsType.Windows && "Windows-hmmm"}

+

{osCheck() === OsType.Linux && "Linux-hmmm"}

+
+ ); +}; + +export default App; + ``` From 12655dcad080310936a2c3c6ca00c3b8bde2524c Mon Sep 17 00:00:00 2001 From: Maifee Ul Asad <29339330+maifeeulasad@users.noreply.github.com> Date: Sun, 25 Sep 2022 13:40:38 +0600 Subject: [PATCH 06/13] delete lib directory as publication is done completely by CI/CD, no need to keep track of what is being deployed by whom --- lib/index.d.ts | 1 - lib/index.js | 23 ----------------------- 2 files changed, 24 deletions(-) delete mode 100644 lib/index.d.ts delete mode 100644 lib/index.js diff --git a/lib/index.d.ts b/lib/index.d.ts deleted file mode 100644 index 33900cb..0000000 --- a/lib/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare const osCheck: () => "Mac OS" | "iOS" | "Windows" | "Android" | "Linux" | undefined; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 27f9f66..0000000 --- a/lib/index.js +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; -const osCheck = () => { - const userAgent = window.navigator.userAgent; - const platform = window.navigator.platform; - const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K', 'darwin']; - const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE']; - const iosPlatforms = ['iPhone', 'iPad', 'iPod']; - if (macosPlatforms.indexOf(platform) !== -1) { - return 'Mac OS'; - } - else if (iosPlatforms.indexOf(platform) !== -1) { - return 'iOS'; - } - else if (windowsPlatforms.indexOf(platform) !== -1) { - return 'Windows'; - } - else if (/Android/.test(userAgent)) { - return 'Android'; - } - else if (/Linux/.test(platform)) { - return 'Linux'; - } -}; From ebe01ada1e5c20a28d34056e45302a8f598422b5 Mon Sep 17 00:00:00 2001 From: maifeeulasad Date: Thu, 16 Nov 2023 13:16:56 +0600 Subject: [PATCH 07/13] [doc]: added ts documentation; --- index.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/index.ts b/index.ts index b03a41a..fbaf122 100644 --- a/index.ts +++ b/index.ts @@ -1,3 +1,6 @@ +/** + * Enumeration for different types of operating systems. + */ enum OsType { MacOS = "MacOS", iOS = "iOS", @@ -7,6 +10,22 @@ enum OsType { Others = "Others OS", } +/** + * Determines the operating system of the user's device. + * It uses the navigator's user agent and platform information to identify the OS. + * + * @returns {OsType} The detected type of operating system. + * + * @example + * import { osCheck, OsType } from "os-check"; + * + * const userOS = osCheck(); + * console.log(`The user's operating system is: ${userOS}`); + * + * @note + * - This function may not be accurate in all cases, as the user agent can be spoofed. + * - It covers major operating systems but might not detect all existing or future OS types. + */ const osCheck = (): OsType => { const userAgent = window.navigator.userAgent; const platform = window.navigator.platform; From a0d7b98415ba1a68e74b3a782cb9ed2267051541 Mon Sep 17 00:00:00 2001 From: Maifee Ul Asad <29339330+maifeeulasad@users.noreply.github.com> Date: Mon, 24 Mar 2025 19:30:09 +0600 Subject: [PATCH 08/13] [chores]: added badges for npm, github, bundlephobia; --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index d1efd50..dd88699 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,29 @@ # os-check +

+ + npm version + + + minified + + + minified + gzipped + +

+ +

+ + GitHub stars + + + GitHub watchers + + + Commits after release + +

+ NPM : https://www.npmjs.com/package/os-check ``` From cbbecb1365f3f352d220ab09de7eea30e8f790d6 Mon Sep 17 00:00:00 2001 From: Maifee Ul Asad <29339330+maifeeulasad@users.noreply.github.com> Date: Mon, 24 Mar 2025 19:31:34 +0600 Subject: [PATCH 09/13] [node,npm]: corrected `main` to `lib/index.js`, instead of `index.ts`; --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e939161..8c889c6 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "os-check", "version": "2.4.0", "description": "Check OS of the host system", - "main": "index.ts", + "main": "lib/index.js", "scripts": { "prepare": "npm run build", "build": "tsc" From 5b5be103c063580c15b6bac162fc8fbd073a8172 Mon Sep 17 00:00:00 2001 From: Maifee Ul Asad <29339330+maifeeulasad@users.noreply.github.com> Date: Mon, 24 Mar 2025 19:32:50 +0600 Subject: [PATCH 10/13] [version]: bump up version from `2.4.0` to `2.5.0`; --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8c889c6..b7a979e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "os-check", - "version": "2.4.0", + "version": "2.5.0", "description": "Check OS of the host system", "main": "lib/index.js", "scripts": { From 03f2a298ca9e02b7878d14817196d0cd5c6f6717 Mon Sep 17 00:00:00 2001 From: Maifee Ul Asad <29339330+maifeeulasad@users.noreply.github.com> Date: Tue, 25 Mar 2025 14:29:03 +0600 Subject: [PATCH 11/13] [chores]: updated readme; --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index dd88699..66f26a2 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ import { osCheck, OsType } from "os-check"; const App = () => { useEffect(() => { + // only for testing purposes // alert(osCheck()) }, []); return ( From b61dc03d5aed7e14ae4872f45627e818964892cb Mon Sep 17 00:00:00 2001 From: Maifee Ul Asad <29339330+maifeeulasad@users.noreply.github.com> Date: Thu, 27 Mar 2025 15:48:47 +0600 Subject: [PATCH 12/13] [chores]: added npm chart showing downloads; --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 66f26a2..ed7b080 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -# os-check +# os-check [![NPM Downloads][downloads-image]][downloads-url] + +[downloads-image]: https://img.shields.io/npm/dm/os-check.svg +[downloads-url]: https://npmcharts.com/compare/os-check?minimal=true

From b6e6a43b2be97202c78e11c5ed99351b02a80bfa Mon Sep 17 00:00:00 2001 From: Maifee Ul Asad <29339330+maifeeulasad@users.noreply.github.com> Date: Thu, 26 Feb 2026 05:47:59 +0600 Subject: [PATCH 13/13] [action]: use node `24`; use action `@v4`; --- .github/workflows/automation.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/automation.yaml b/.github/workflows/automation.yaml index a231368..6e11999 100644 --- a/.github/workflows/automation.yaml +++ b/.github/workflows/automation.yaml @@ -10,12 +10,12 @@ jobs: strategy: matrix: - node-version: [16.x] + node-version: [24.x] registry-url: ['https://registry.npmjs.org'] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} registry-url: ${{ matrix.registry-url }}