@naverpay/device-info 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -10
- package/index.d.ts +15 -5
- package/package.json +1 -2
- package/hooks/postinstall.js +0 -34
package/README.md
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# @naverpay/device-info
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A library for converting device IDs to user-friendly model names.
|
|
4
4
|
|
|
5
|
-
- iOS
|
|
6
|
-
-
|
|
5
|
+
- For iOS, it maps `Identifier` to `Generation`.
|
|
6
|
+
- For Android, it maps `Model` to Marketing `Name`.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- https://
|
|
8
|
+
These data are collected based on the following documents and updated every Monday:
|
|
9
|
+
|
|
10
|
+
- <https://storage.googleapis.com/play_public/supported_devices.html>
|
|
11
|
+
- <https://theapplewiki.com/wiki/Models>
|
|
11
12
|
|
|
12
13
|
## Installation
|
|
13
14
|
|
|
@@ -18,9 +19,9 @@ npm install --save @naverpay/device-info
|
|
|
18
19
|
## Usage
|
|
19
20
|
|
|
20
21
|
```javascript
|
|
21
|
-
import iOSDeviceInfo from
|
|
22
|
-
import androidDeviceInfo from
|
|
22
|
+
import iOSDeviceInfo from "@naverpay/device-info/ios.json";
|
|
23
|
+
import androidDeviceInfo from "@naverpay/device-info/aos.json";
|
|
23
24
|
|
|
24
|
-
console.log(iosDeviceInfo[
|
|
25
|
-
console.log(androidDeviceInfo[
|
|
25
|
+
console.log(iosDeviceInfo["iPhone15,4"]); // "iPhone 15"
|
|
26
|
+
console.log(androidDeviceInfo["SM-S901B"]); // "Galaxy S22"
|
|
26
27
|
```
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
1
|
+
declare module "@naverpay/device-info" {
|
|
2
|
+
export interface DeviceInfo {
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const iOS: DeviceInfo;
|
|
7
|
+
const aos: DeviceInfo;
|
|
8
|
+
const date: string;
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
iOS,
|
|
12
|
+
aos,
|
|
13
|
+
date,
|
|
14
|
+
};
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naverpay/device-info",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Device information",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"node-html-parser": "^6.1.12"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"postinstall": "node ./hooks/postinstall.js",
|
|
23
22
|
"crawling": "node src/crawling.js",
|
|
24
23
|
"release": "changeset publish"
|
|
25
24
|
}
|
package/hooks/postinstall.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
|
|
5
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
-
const __dirname = path.dirname(__filename);
|
|
7
|
-
const packageJsonPath = path.join(__dirname, "../package.json");
|
|
8
|
-
|
|
9
|
-
const filePath = path.join(__dirname, "../date.js");
|
|
10
|
-
|
|
11
|
-
const readFiles = async () => {
|
|
12
|
-
try {
|
|
13
|
-
const autoGeneratedFileData = await fs.promises.readFile(
|
|
14
|
-
"./date.js",
|
|
15
|
-
"utf8"
|
|
16
|
-
);
|
|
17
|
-
const dateMatch = autoGeneratedFileData.match(/const date = "(.*?)"/);
|
|
18
|
-
|
|
19
|
-
const packageJsonData = await fs.promises.readFile(packageJsonPath, "utf8");
|
|
20
|
-
const packageJson = JSON.parse(packageJsonData);
|
|
21
|
-
|
|
22
|
-
if (dateMatch && dateMatch[1]) {
|
|
23
|
-
console.log(
|
|
24
|
-
`${packageJson.name}@${packageJson.version} was automatically generated on:`,
|
|
25
|
-
dateMatch[1]
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
} catch (err) {
|
|
29
|
-
console.error("An error occurred while reading the files:", err);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
readFiles();
|