Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"gettext-parser": "1.3.1",
"gl-matrix": "^3.4.3",
"intersection-observer": "^0.12.2",
"ios-device-list": "^1.1.35",
"ios-device-list": "1.1.37",
"jed": "^1.1.0",
"js-beautify": "^1.14.4",
"js-cookie": "3.0.1",
Expand Down
19 changes: 13 additions & 6 deletions scripts/extract-ios-device-names.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* eslint-disable import/no-nodejs-modules */
/* eslint-env node */
import path from 'path';
import fs from 'fs';
import path from 'path';

import prettier from 'prettier';

//joining path of directory
// joining path of directory
const tmpOutputPath = path.join(
__dirname,
'../static/app/constants/ios-device-list.tmp.tsx'
Expand All @@ -17,9 +18,11 @@ async function getDefinitionFiles(): Promise<string[]> {

const maybeJSONFiles = await fs.readdirSync(directoryPath);

//listing all files using forEach
// listing all files using forEach
maybeJSONFiles.forEach(file => {
if (!file.endsWith('.json') || file === 'package.json') return;
if (!file.endsWith('.json') || file === 'package.json') {
return;
}

files.push(path.join(path.resolve(directoryPath), file));
});
Expand All @@ -32,7 +35,7 @@ type Identifier = string;

type Mapping = Record<Identifier, Generation>;

async function collectDefinitions(files: string[]): Promise<Mapping> {
function collectDefinitions(files: string[]): Mapping {
const definitions: Mapping = {};

const queue = [...files];
Expand All @@ -52,6 +55,10 @@ async function collectDefinitions(files: string[]): Promise<Mapping> {
}

for (let i = 0; i < content.length; i++) {
if (!content[i].Identifier) {
continue;
}

definitions[content[i].Identifier] = content[i].Generation;
}
}
Expand Down Expand Up @@ -86,7 +93,7 @@ const formatOutput = async (unformatted: string) => {

export async function extractIOSDeviceNames() {
const files = await getDefinitionFiles();
const definitions = await collectDefinitions(files);
const definitions = collectDefinitions(files);
const formatted = await formatOutput(
template(JSON.stringify(definitions, undefined, 2))
);
Expand Down
47 changes: 44 additions & 3 deletions static/app/constants/ios-device-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const iOSDeviceMapping: Record<string, string> = {
'iPhone10,6': 'iPhone X',
'iPhone11,8': 'iPhone XR',
'iPhone11,2': 'iPhone XS',
'iPhone11,4': 'iPhone XS Max',
'iPhone11,6': 'iPhone XS Max',
'iPhone11,4': 'iPhone XS Max',
'iPhone12,1': 'iPhone 11',
'iPhone12,3': 'iPhone 11 Pro',
'iPhone12,5': 'iPhone 11 Pro Max',
Expand All @@ -51,6 +51,15 @@ const iOSDeviceMapping: Record<string, string> = {
'iPhone13,2': 'iPhone 12',
'iPhone13,3': 'iPhone 12 Pro',
'iPhone13,4': 'iPhone 12 Pro Max',
'iPhone14,4': 'iPhone 13 mini',
'iPhone14,5': 'iPhone 13',
'iPhone14,2': 'iPhone 13 Pro',
'iPhone14,3': 'iPhone 13 Pro Max',
'iPhone14,6': 'iPhone SE (3rd generation)',
'iPhone14,7': 'iPhone 14',
'iPhone14,8': 'iPhone 14 Plus',
'iPhone15,2': 'iPhone 14 Pro',
'iPhone15,3': 'iPhone 14 Pro Max',
'iPad6,7': 'iPad Pro (12.9-inch)',
'iPad6,8': 'iPad Pro (12.9-inch)',
'iPad6,3': 'iPad Pro (9.7-inch)',
Expand All @@ -71,6 +80,14 @@ const iOSDeviceMapping: Record<string, string> = {
'iPad8,10': 'iPad Pro (11-inch) (2nd generation)',
'iPad8,11': 'iPad Pro (12.9-inch) (4th generation)',
'iPad8,12': 'iPad Pro (12.9-inch) (4th generation)',
'iPad13,4': 'iPad Pro (11-inch) (3rd generation)',
'iPad13,5': 'iPad Pro (11-inch) (3rd generation)',
'iPad13,6': 'iPad Pro (11-inch) (3rd generation)',
'iPad13,7': 'iPad Pro (11-inch) (3rd generation)',
'iPad13,8': 'iPad Pro (12.9-inch) (5th generation)',
'iPad13,9': 'iPad Pro (12.9-inch) (5th generation)',
'iPad13,10': 'iPad Pro (12.9-inch) (5th generation)',
'iPad13,11': 'iPad Pro (12.9-inch) (5th generation)',
'iPad2,5': 'iPad mini',
'iPad2,6': 'iPad mini',
'iPad2,7': 'iPad mini',
Expand All @@ -84,6 +101,8 @@ const iOSDeviceMapping: Record<string, string> = {
'iPad5,2': 'iPad mini 4',
'iPad11,1': 'iPad mini (5th generation)',
'iPad11,2': 'iPad mini (5th generation)',
'iPad14,1': 'iPad mini (6th generation)',
'iPad14,2': 'iPad mini (6th generation)',
'iPad4,1': 'iPad Air',
'iPad4,2': 'iPad Air',
'iPad4,3': 'iPad Air',
Expand All @@ -93,6 +112,8 @@ const iOSDeviceMapping: Record<string, string> = {
'iPad11,4': 'iPad Air (3rd generation)',
'iPad13,1': 'iPad Air (4th generation)',
'iPad13,2': 'iPad Air (4th generation)',
'iPad13,16': 'iPad Air (5th generation)',
'iPad13,17': 'iPad Air (5th generation)',
'iPad1,1': 'iPad',
'iPad2,1': 'iPad 2',
'iPad2,2': 'iPad 2',
Expand All @@ -112,6 +133,8 @@ const iOSDeviceMapping: Record<string, string> = {
'iPad7,12': 'iPad (7th generation)',
'iPad11,6': 'iPad (8th generation)',
'iPad11,7': 'iPad (8th generation)',
'iPad12,1': 'iPad (9th generation)',
'iPad12,2': 'iPad (9th generation)',
'AudioAccessory1,1': 'HomePod',
'AudioAccessory1,2': 'HomePod',
'AudioAccessory5,1': 'HomePod mini',
Expand Down Expand Up @@ -141,15 +164,33 @@ const iOSDeviceMapping: Record<string, string> = {
'Watch6,2': 'Apple Watch Series 6',
'Watch6,3': 'Apple Watch Series 6',
'Watch6,4': 'Apple Watch Series 6',
'Watch6,6': 'Apple Watch Series 7',
'Watch6,7': 'Apple Watch Series 7',
'Watch6,8': 'Apple Watch Series 7',
'Watch6,9': 'Apple Watch Series 7',
'Watch6,10': 'Apple Watch SE (2nd generation)',
'Watch6,11': 'Apple Watch SE (2nd generation)',
'Watch6,12': 'Apple Watch SE (2nd generation)',
'Watch6,13': 'Apple Watch SE (2nd generation)',
'Watch6,14': 'Apple Watch Series 8',
'Watch6,15': 'Apple Watch Series 8',
'Watch6,16': 'Apple Watch Series 8',
'Watch6,17': 'Apple Watch Series 8',
'Watch6,18': 'Apple Watch Ultra',
'AppleTV1,1': 'Apple TV (1st generation)',
'AppleTV2,1': 'Apple TV (2nd generation)',
'AppleTV3,1': 'Apple TV (3rd generation)',
'AppleTV3,2': 'Apple TV (3rd generation)',
'AppleTV5,3': 'Apple TV (4th generation)',
'AppleTV6,2': 'Apple TV 4K',
'AppleTV11,1': 'Apple TV 4K (2nd generation)',
'AirTag1,1': 'AirTag',
'AirPods1,1': 'AirPods (1st generation)',
'AirPods2,1': 'AirPods (2nd generation)',
'iProd8,1': 'AirPods Pro',
'AirPods2,1,AirPods2,1': 'AirPods (2nd generation)',
'AirPods1,3,Audio2,1': 'AirPods (3rd generation)',
'AirPods2,2,AirPodsPro1,1,iProd8,1': 'AirPods Pro',
'AirPodsPro1,2': 'AirPods Pro (2nd generation)',
'AirPodsMax1,1,iProd8,6': 'AirPods Max',
};

export {iOSDeviceMapping};
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6709,10 +6709,10 @@ invariant@^2.2.1, invariant@^2.2.4:
dependencies:
loose-envify "^1.0.0"

ios-device-list@^1.1.35:
version "1.1.35"
resolved "https://registry.yarnpkg.com/ios-device-list/-/ios-device-list-1.1.35.tgz#cddc2ed9634f4f1af1061016caf31ef4f4dc5307"
integrity sha512-ESaQizoD8nGdw8vhkYqab0jbPcSPnpGmqhwd3aqtyan9AZFNnQdj31ic6FdDd+/gUqp5N6RFU/ODxVKGwDhoMw==
ios-device-list@1.1.37:
version "1.1.37"
resolved "https://registry.yarnpkg.com/ios-device-list/-/ios-device-list-1.1.37.tgz#0461dcba91ff824422740cfabc32490bfd95e686"
integrity sha512-0CS8kand3WDF58GtQV7AlFl9mONeHyQDtrypNEVSUyFsxNcbvj/o4gGeS/LNrQAK8V8V4rSIIpxx3hBVDDFwIg==
dependencies:
lodash.clonedeep "^4.5.0"
lodash.flatten "^4.4.0"
Expand Down