Skip to content

Commit

Permalink
Release v3.0.0 and down sizing (#5)
Browse files Browse the repository at this point in the history
* Release v3.0.0 and down sizing
* Fixed testCreator and package.json
  • Loading branch information
TessavWalstijn authored Feb 9, 2024
1 parent d453723 commit c94e1c6
Show file tree
Hide file tree
Showing 20 changed files with 245 additions and 43 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

jobs:
publish:
- name: Publish browser-agent
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -27,3 +28,26 @@ jobs:
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
publish:
- name: Publish browser-agent/collection
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 18
registry-url: https://registry.npmjs.org
- name: Set correct yarn
run: corepack enable
- name: Install
run: yarn
- name: Generate
run: yarn collection:update
- name: Build
run: yarn collection:build
- name: Publish
run: yarn collection:publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,6 @@ dist
*.njsproj
*.sln
*.sw?

# Ignore collection generated code
collection
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ out
*.sln
*.sw?

#
collection
*.test.ts
*.userAgents.ts
tsconfig.*.json
vitest.*.ts
.eslint
Expand Down
108 changes: 108 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Browser Agent Changelog

## Release [v3.0.0](https://github.com/TessavWalstijn/browser-agent/releases/tag/v2.0.2) - 2024-02-09

### Added

- npm package `browser-agent/collection`
the place for the userAgent collection
- Changelog

### Removed

- userAgent collection from npm package `browser-agent`
(breaking change if you used the userAgent collection)

## Release [v2.0.2](https://github.com/TessavWalstijn/browser-agent/releases/tag/v2.0.2) - 2024-02-06

### Added

- Package.json types path for TypeScript

### Fixed

- Package.json require and import paths

## Release [v2.0.1](https://github.com/TessavWalstijn/browser-agent/releases/tag/v2.0.1) - 2024-02-06

### Added

- Contribution Guidelines
- Code of Conduct

### Fixed

- Testing step in publish pipeline
- Actual build files in package

## Release [v2.0.0](https://github.com/TessavWalstijn/browser-agent/releases/tag/v2.0.0) - 2024-02-03

### Added

- Builds for npm
- CJS version
- ESM version
- Tests
- Build test on CJS
- Build test on ESM
- Chrome test
- Edge test
- Firefox test
- Internet Explorer test
- Safari test
- userAgents (3234 of them!)

### Changed

- v1.0.1 moved to `./classic` folder
- Original functions rewritten to TypeScript
- Browsers
- Chrome
- Edge
- Firefox
- Internet Explorer
- Safari
- Operating Systems
- Windows
- Mac OS
- Ubuntu
- Fedora
- Red Hat
- Linux Mint
- CentOS
- Debian
- Linux
- Android
- iOS
- iPadOS
- Unix

## Release [v1.0.1](https://github.com/TessavWalstijn/browser-agent/releases/tag/v1.0.1) - 2022-12-26

### Fixed

- Typo in Firefox.js

## Release [v1.0.0](https://github.com/TessavWalstijn/browser-agent/releases/tag/v1.0.0) - 2022-12-26

### Added

- **Browsers:**
- Chrome
- Edge
- Firefox
- IE
- Safari
- **Operating Systems:**
- Windows
- Mac OS
- Ubuntu
- Fedora
- Red Hat
- Linux Mint
- CentOS
- Debian
- Linux
- Android
- iOS
- Unix
15 changes: 15 additions & 0 deletions README-COLLECTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Collection package for `browser-agent`

### Indexed browsers

- Chrome
- Edge
- Firefox
- IE
- Safari

## How to contribute

Before starting, please read our [Code of Conduct](./CODE_OF_CONDUCT./) and [Contributing Guidelines](./CONTRIBUTING_GUIDELINES.md) for detailed information and instructions on contributing to this repository.

Please note that `browser-agent/collection` is a generated collection from the code-base of `browser-agent`
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Check Operating System, Browser Type and Version

### Indexed browsers:
### Browser checks:

- Chrome
- Edge
- Firefox
- IE
- Safari

### Indexed operating systems:
### Operating System checks:

- Windows
- Mac OS
Expand Down Expand Up @@ -42,15 +42,21 @@ const shortcutToolTipLabel = (event: Keyboard) => {
const browserAgent = require('browser-agent')
const { detectMac } = browserAgent

const shortcutToolTipLabel = (event: Keyboard) => {
const shortcutToolTipLabel = (event) => {
const alt = `${detectMac(userAgent) ? '' : 'alt'}`
const shift = `${detectMac(userAgent) ? '' : 'shift'}`
return `${alt} + ${shift} + T`
}
```

## How to contribute
## Browser Agent packages notice

Before starting, please read our [Code of Conduct](./CODE_OF_CONDUCT./) and [Contributing Guidelines](./CONTRIBUTING_GUIDELINES.md) for detailed information and instructions on contributing to this repository.
The npm packages:
- `browser-agent`
- `browser-agent/collection`

Have the same version to garuntee compatibility with each other.

## How to contribute

Before starting, please read our [Code of Conduct](./CODE_OF_CONDUCT./) and [Contributing Guidelines](./CONTRIBUTING_GUIDELINES.md) for detailed information and instructions on contributing to this repository.
12 changes: 8 additions & 4 deletions build-tests/cjs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ import {
detectFirefox,
detectIE,
detectSafari,
eBrowserType,
// @ts-ignore
} from './dist/index.cjs'
import { collectionUserAgents } from '../source/browsers/userAgents.js'
import { testBrowser } from '../source/utils/testCreator'

const {
userAgentsChrome,
userAgentsEdge,
userAgentsFirefox,
userAgentsIE,
userAgentsSafari,
eBrowserType,
// @ts-ignore
} from './dist/index.cjs'
import { testBrowser } from '../source/utils/testCreator'
} = collectionUserAgents

describe('Chrome tests', () => {
testBrowser({
Expand Down
12 changes: 8 additions & 4 deletions build-tests/esm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ import {
detectFirefox,
detectIE,
detectSafari,
eBrowserType,
// @ts-ignore
} from './dist/index.js'
import { collectionUserAgents } from '../source/browsers/userAgents.js'
import { testBrowser } from '../source/utils/testCreator'

const {
userAgentsChrome,
userAgentsEdge,
userAgentsFirefox,
userAgentsIE,
userAgentsSafari,
eBrowserType,
// @ts-ignore
} from './dist/index.js'
import { testBrowser } from '../source/utils/testCreator'
} = collectionUserAgents

describe('Chrome tests', () => {
testBrowser({
Expand Down
21 changes: 21 additions & 0 deletions build/collection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import fs from 'fs'
import pjson from '../package.json' assert { type: 'json' }
import base from '../package-collection.json' assert { type: 'json' }

const readme = fs.readFileSync('./README-COLLECTION.md', {
flag: 'r',
})

// Keep versions in sync
const packageCollection = {
...base,
version: pjson.version,
}

fs.writeFileSync(
'./collection/package.json',
JSON.stringify(packageCollection),
{ flag: 'w+' },
)

fs.writeFileSync('./collection/README.md', readme, { flag: 'w+' })
17 changes: 17 additions & 0 deletions package-collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "browser-agent/collection",
"description": "Use userAgent collection of browser-agent",
"type": "module",
"repository": "[email protected]:TessavWalstijn/browser-id.git",
"author": "TessavWalstijn <[email protected]>",
"license": "MIT",
"types": "./dist/userAgents.d.ts",
"exports": {
"require": "./dist/userAgents.cjs",
"import": "./dist/userAgents.js"
},
"main": "./dist/userAgents.cjs",
"engines": {
"node": ">= 16"
}
}
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "browser-agent",
"version": "2.0.2",
"version": "3.0.0",
"description": "Get users browser & os information (Uses userAgent)",
"type": "module",
"repository": "[email protected]:TessavWalstijn/browser-id.git",
"repository": "[email protected]:TessavWalstijn/browser-agent.git",
"author": "TessavWalstijn <[email protected]>",
"license": "MIT",
"packageManager": "[email protected]",
Expand All @@ -14,8 +14,11 @@
},
"main": "./dist/index.cjs",
"scripts": {
"collection:update": "ts-node --project tsconfig.dev.json ./build/collection",
"collection:build": "cd ./collection && tsup ../source/browsers/userAgents.ts --format esm,cjs,iife --dts",
"collection:publish": "cd ./collection && npm publish --access public",
"dev": "ts-node --project tsconfig.dev.json ./source/dev",
"build": "tsup source/index.ts --format esm,cjs --dts",
"build": "tsup source/index.ts --format esm,cjs,iife --dts",
"build:test": "vitest --config vitest.build.config.ts",
"build:tsc": "yarn build:esm && yarn build:cjs",
"build:esm": "npx tsc --build tsconfig.esm.json",
Expand Down
1 change: 0 additions & 1 deletion source/browsers/Chrome/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './chrome.js'
export * from './chrome.userAgents.js'
1 change: 0 additions & 1 deletion source/browsers/Edge/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './edge.js'
export * from './edge.userAgents.js'
1 change: 0 additions & 1 deletion source/browsers/Firefox/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './firefox.js'
export * from './firefox.userAgents.js'
1 change: 0 additions & 1 deletion source/browsers/IE/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './ie.js'
export * from './ie.userAgents.js'
1 change: 0 additions & 1 deletion source/browsers/Safari/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './safari.js'
export * from './safari.userAgents.js'
1 change: 0 additions & 1 deletion source/browsers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ export * from './Edge/index.js'
export * from './Firefox/index.js'
export * from './IE/index.js'
export * from './Safari/index.js'
export * from './userAgents.js'
22 changes: 7 additions & 15 deletions source/browsers/userAgents.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import { eBrowserType, iBrowser } from '../types/browser.types.js'
import { userAgentsChrome } from './Chrome/index.js'
import { userAgentsEdge } from './Edge/index.js'
import { userAgentsFirefox } from './Firefox/index.js'
import { userAgentsIE } from './IE/index.js'
import { userAgentsSafari } from './Safari/index.js'
import { eBrowserType } from '../types/browser.types.js'
import { iCollectionUserAgents, iUserAgent } from '../types/userAgent.types.js'
import { userAgentsChrome } from './Chrome/chrome.userAgents.js'
import { userAgentsEdge } from './Edge/edge.userAgents.js'
import { userAgentsFirefox } from './Firefox/firefox.userAgents.js'
import { userAgentsIE } from './IE/ie.userAgents.js'
import { userAgentsSafari } from './Safari/safari.userAgents.js'
import { getBrowser } from './_GetBrowser/getBrowser.js'

export interface iUserAgent {
values: string[]
browser: iBrowser
}

export interface iCollectionUserAgents {
[key: string]: iUserAgent[]
}

export const collectionUserAgents: iCollectionUserAgents = {
userAgentsChrome,
userAgentsEdge,
Expand Down
10 changes: 10 additions & 0 deletions source/types/userAgent.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { iBrowser } from './browser.types'

export interface iUserAgent {
values: string[]
browser: iBrowser
}

export interface iCollectionUserAgents {
[key: string]: iUserAgent[]
}
Loading

0 comments on commit c94e1c6

Please sign in to comment.