-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
2,481 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.DS_STORE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"env": { | ||
"jest": true | ||
} | ||
} |
Binary file added
BIN
+1.3 KB
...Containers/Bundle/Application/43FB53D5-6F42-4F38-A810-6C1A28B393E9/example.app/Info.plist
Binary file not shown.
Binary file added
BIN
+1.29 KB
...Containers/Bundle/Application/950806E1-3259-4089-8EF3-DF0941E3B5B7/example.app/Info.plist
Binary file not shown.
18 changes: 18 additions & 0 deletions
18
__tests__/Devices/148019A3-566F-4C21-A4FC-6FD75D9F051E/device.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>UDID</key> | ||
<string>148019A3-566F-4C21-A4FC-6FD75D9F051E</string> | ||
<key>deviceType</key> | ||
<string>com.apple.CoreSimulator.SimDeviceType.iPhone-7</string> | ||
<key>isDeleted</key> | ||
<false/> | ||
<key>name</key> | ||
<string>iPhone 7</string> | ||
<key>runtime</key> | ||
<string>com.apple.CoreSimulator.SimRuntime.iOS-12-1</string> | ||
<key>state</key> | ||
<integer>3</integer> | ||
</dict> | ||
</plist> |
Binary file added
BIN
+1.29 KB
...Containers/Bundle/Application/B3674201-2F90-4759-988E-CDB42181FD80/example.app/Info.plist
Binary file not shown.
18 changes: 18 additions & 0 deletions
18
__tests__/Devices/1E756F87-FF14-45C0-9775-A4469F72599E/device.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>UDID</key> | ||
<string>1E756F87-FF14-45C0-9775-A4469F72599E</string> | ||
<key>deviceType</key> | ||
<string>com.apple.CoreSimulator.SimDeviceType.iPad-Air</string> | ||
<key>isDeleted</key> | ||
<false/> | ||
<key>name</key> | ||
<string>iPad Air</string> | ||
<key>runtime</key> | ||
<string>com.apple.CoreSimulator.SimRuntime.iOS-9-3</string> | ||
<key>state</key> | ||
<integer>3</integer> | ||
</dict> | ||
</plist> |
16 changes: 16 additions & 0 deletions
16
__tests__/Devices/7BBD33B7-63B0-4D96-9BE0-BDCA97FE89E0/device.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>UDID</key> | ||
<string>7BBD33B7-63B0-4D96-9BE0-BDCA97FE89E0</string> | ||
<key>deviceType</key> | ||
<string>com.apple.CoreSimulator.SimDeviceType.iPhone-6s</string> | ||
<key>name</key> | ||
<string>iPhone 6s</string> | ||
<key>runtime</key> | ||
<string>com.apple.CoreSimulator.SimRuntime.iOS-11-4</string> | ||
<key>state</key> | ||
<integer>1</integer> | ||
</dict> | ||
</plist> |
Binary file added
BIN
+1.29 KB
...Containers/Bundle/Application/4FEF6828-573D-4ACA-922D-85C1EEA7E509/example.app/Info.plist
Binary file not shown.
18 changes: 18 additions & 0 deletions
18
__tests__/Devices/C321F874-FA51-4DC5-8B9A-2E6E095D8C90/device.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>UDID</key> | ||
<string>C321F874-FA51-4DC5-8B9A-2E6E095D8C90</string> | ||
<key>deviceType</key> | ||
<string>com.apple.CoreSimulator.SimDeviceType.iPhone-XR</string> | ||
<key>isDeleted</key> | ||
<false/> | ||
<key>name</key> | ||
<string>iPhone XR</string> | ||
<key>runtime</key> | ||
<string>com.apple.CoreSimulator.SimRuntime.iOS-12-1</string> | ||
<key>state</key> | ||
<integer>3</integer> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`should get devices correctly 1`] = ` | ||
Array [ | ||
Object { | ||
"UDID": "148019A3-566F-4C21-A4FC-6FD75D9F051E", | ||
"apps": Array [ | ||
Object { | ||
"CFBundleDisplayName": "pasta", | ||
"CFBundleIdentifier": "org.reactjs.native.example.pasta", | ||
"CFBundleShortVersionString": "3.0", | ||
"CFBundleVersion": "8", | ||
"file": "/home/circleci/ios-simulator-app-exporter/__tests__/Devices/148019A3-566F-4C21-A4FC-6FD75D9F051E/data/Containers/Bundle/Application/43FB53D5-6F42-4F38-A810-6C1A28B393E9/example.app", | ||
}, | ||
Object { | ||
"CFBundleDisplayName": "example", | ||
"CFBundleIdentifier": "org.reactjs.native.example.example", | ||
"CFBundleShortVersionString": "1.0", | ||
"CFBundleVersion": "1", | ||
"file": "/home/circleci/ios-simulator-app-exporter/__tests__/Devices/148019A3-566F-4C21-A4FC-6FD75D9F051E/data/Containers/Bundle/Application/950806E1-3259-4089-8EF3-DF0941E3B5B7/example.app", | ||
}, | ||
], | ||
"deviceType": "com.apple.CoreSimulator.SimDeviceType.iPhone-7", | ||
"isDeleted": false, | ||
"name": "iPhone 7", | ||
"path": "/home/circleci/ios-simulator-app-exporter/__tests__/Devices/148019A3-566F-4C21-A4FC-6FD75D9F051E", | ||
"runtime": "com.apple.CoreSimulator.SimRuntime.iOS-12-1", | ||
"state": 3, | ||
}, | ||
Object { | ||
"UDID": "1E756F87-FF14-45C0-9775-A4469F72599E", | ||
"apps": Array [ | ||
Object { | ||
"CFBundleDisplayName": "example", | ||
"CFBundleIdentifier": "org.reactjs.native.example.example", | ||
"CFBundleShortVersionString": "1.0", | ||
"CFBundleVersion": "1", | ||
"file": "/home/circleci/ios-simulator-app-exporter/__tests__/Devices/1E756F87-FF14-45C0-9775-A4469F72599E/data/Containers/Bundle/Application/B3674201-2F90-4759-988E-CDB42181FD80/example.app", | ||
}, | ||
], | ||
"deviceType": "com.apple.CoreSimulator.SimDeviceType.iPad-Air", | ||
"isDeleted": false, | ||
"name": "iPad Air", | ||
"path": "/home/circleci/ios-simulator-app-exporter/__tests__/Devices/1E756F87-FF14-45C0-9775-A4469F72599E", | ||
"runtime": "com.apple.CoreSimulator.SimRuntime.iOS-9-3", | ||
"state": 3, | ||
}, | ||
Object { | ||
"UDID": "7BBD33B7-63B0-4D96-9BE0-BDCA97FE89E0", | ||
"apps": Array [], | ||
"deviceType": "com.apple.CoreSimulator.SimDeviceType.iPhone-6s", | ||
"name": "iPhone 6s", | ||
"path": "/home/circleci/ios-simulator-app-exporter/__tests__/Devices/7BBD33B7-63B0-4D96-9BE0-BDCA97FE89E0", | ||
"runtime": "com.apple.CoreSimulator.SimRuntime.iOS-11-4", | ||
"state": 1, | ||
}, | ||
Object { | ||
"UDID": "C321F874-FA51-4DC5-8B9A-2E6E095D8C90", | ||
"apps": Array [ | ||
Object { | ||
"CFBundleDisplayName": "example", | ||
"CFBundleIdentifier": "org.reactjs.native.example.example", | ||
"CFBundleShortVersionString": "1.0", | ||
"CFBundleVersion": "1", | ||
"file": "/home/circleci/ios-simulator-app-exporter/__tests__/Devices/C321F874-FA51-4DC5-8B9A-2E6E095D8C90/data/Containers/Bundle/Application/4FEF6828-573D-4ACA-922D-85C1EEA7E509/example.app", | ||
}, | ||
], | ||
"deviceType": "com.apple.CoreSimulator.SimDeviceType.iPhone-XR", | ||
"isDeleted": false, | ||
"name": "iPhone XR", | ||
"path": "/home/circleci/ios-simulator-app-exporter/__tests__/Devices/C321F874-FA51-4DC5-8B9A-2E6E095D8C90", | ||
"runtime": "com.apple.CoreSimulator.SimRuntime.iOS-12-1", | ||
"state": 3, | ||
}, | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const getAppsByDevice = require('../getAppsByDevice'); | ||
|
||
it('should get devices correctly', () => { | ||
expect(getAppsByDevice(`${__dirname}/Devices`)).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
const fs = require('fs'); | ||
const { join } = require('path'); | ||
const { homedir } = require('os'); | ||
const plist = require('simple-plist'); | ||
|
||
const DEVICES_PATH = '/Library/Developer/CoreSimulator/Devices/'; | ||
const APPS_PATH = '/data/Containers/Bundle/Application'; | ||
|
||
function getDirectories(source) { | ||
if (!fs.existsSync(source)) { | ||
return []; | ||
} | ||
|
||
return fs | ||
.readdirSync(source) | ||
.map(name => join(source, name)) | ||
.filter(file => fs.lstatSync(file).isDirectory()); | ||
} | ||
|
||
function getAppsByDevice(searchingPath = homedir() + DEVICES_PATH) { | ||
return getDirectories(searchingPath).map(devicePath => { | ||
const device = plist.readFileSync(`${devicePath}/device.plist`); | ||
|
||
return { | ||
path: devicePath, | ||
...device, | ||
apps: getDirectories(devicePath + APPS_PATH).reduce((acc, appPath) => { | ||
const apps = getDirectories(appPath) | ||
.filter(file => file.endsWith('.app')) | ||
.map(file => { | ||
if (fs.existsSync(`${file}/Info.plist`)) { | ||
let app; | ||
|
||
try { | ||
app = plist.readFileSync(`${file}/Info.plist`); | ||
} catch (error) { | ||
console.error(`Something is wrong with ${file}: ${error}`); | ||
} | ||
|
||
if (!app) { | ||
return undefined; | ||
} | ||
|
||
const { | ||
CFBundleDisplayName, | ||
CFBundleIdentifier, | ||
CFBundleShortVersionString, | ||
CFBundleVersion, | ||
} = app; | ||
|
||
return { | ||
file, | ||
CFBundleDisplayName, | ||
CFBundleIdentifier, | ||
CFBundleShortVersionString, | ||
CFBundleVersion, | ||
}; | ||
} | ||
|
||
return undefined; | ||
}) | ||
.filter(app => app); | ||
|
||
return [...acc, ...apps]; | ||
}, []), | ||
}; | ||
}); | ||
} | ||
|
||
module.exports = getAppsByDevice; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"main": "index.js", | ||
"scripts": { | ||
"start": "node index.js", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"test": "jest", | ||
"precommit": "lint-staged" | ||
}, | ||
"author": "Nicolas Charpentier <[email protected]>", | ||
|
@@ -22,6 +22,7 @@ | |
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-jsx-a11y": "^6.1.1", | ||
"eslint-plugin-react": "^7.11.0", | ||
"jest": "^23.6.0", | ||
"lint-staged": "^8.1.0", | ||
"prettier": "1.15.3" | ||
}, | ||
|
Oops, something went wrong.