Skip to content

refactor(system): replace mime db with common dataset #1788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/guide/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,24 @@ For the old `faker.datatype.number` method you should replace with `faker.number
### `allowLeadingZeros` behavior change in `faker.string.numeric`

The `allowLeadingZeros` boolean parameter in `faker.string.numeric` (in the new `string` module) now defaults to `true`. `faker.string.numeric` will now generate numeric strings that could have leading zeros by default.

### Remove of `mime-db`

Before `v8`, Faker generated its mime types definitions based on the [mime-db](https://www.npmjs.com/package/mime-db) dataset.
In `v8` we decided to move away from this massive set and focus on more commonly used mime types.

This essentially means, that we:

- removed most definitions regarding this topic
- no longer support every single mime type
- will return commonly used mime types/file types/file extension more often

::: info
⚠ Depending on your use-case, this could be a breaking change to you!
:::

Functions that are affected by this change are:

- `faker.system.mimeType`
- `faker.system.fileType`
- `faker.system.fileExt`
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"build": "run-s build:clean build:code build:types",
"generate:api-docs": "tsx ./scripts/apidoc.ts",
"generate:locales": "tsx ./scripts/generateLocales.ts",
"copy:mime-types": "tsx ./scripts/copyMimeTypes.ts",
"docs:build": "run-s docs:prepare docs:build:run",
"docs:build:run": "vitepress build docs",
"docs:build:ci": "run-s build docs:build",
Expand Down Expand Up @@ -107,7 +106,6 @@
"eslint-plugin-jsdoc": "~39.6.7",
"eslint-plugin-prettier": "~4.2.1",
"glob": "~8.1.0",
"mime-db": "~1.52.0",
"npm-run-all": "~4.1.5",
"picocolors": "~1.0.0",
"prettier": "2.8.3",
Expand Down
2 changes: 0 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 0 additions & 37 deletions scripts/copyMimeTypes.ts

This file was deleted.

5 changes: 1 addition & 4 deletions src/definitions/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,5 @@ export type SystemDefinitions = LocaleEntry<{
* The mime-type entry details.
*/
export interface SystemMimeTypeEntryDefinitions {
source?: string;
extensions?: string[];
compressible?: boolean;
charset?: string;
extensions: string[];
}
Loading