Skip to content

Commit

Permalink
Add a new device subcommand (implement #70)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dadoum committed Oct 6, 2024
1 parent bd48915 commit d484f73
Show file tree
Hide file tree
Showing 10 changed files with 421 additions and 11 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ I am here to help! I don't want this to finish unmaintained!

```sh
$ sideloader -h
Usage: sideloader [-d] [-h] <command> [<args>]
Usage: sideloader [-d] [--thread-count THREADCOUNT] [-h] <command> [<args>]

Available commands:
app-id Manage App IDs.
cert Manage certificates.
device Manage registered devices.
install Install an application on the device (renames the app, register
the identifier, sign and install automatically).
sign Sign an application bundle.
Expand All @@ -48,7 +49,10 @@ Available commands:

Optional arguments:
-d, --debug Enable debug logging
-h, --help Show this help message and exit
--thread-count THREADCOUNT
Numbers of threads to be used for signing the application
bundle
-h, --help Show this help message and exit
```

Table of Contents
Expand Down
1 change: 0 additions & 1 deletion frontends/cli/dub.selections.json

This file was deleted.

47 changes: 47 additions & 0 deletions frontends/cli/dub.selections.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"fileVersion": 1,
"versions": {
"argparse": "1.3.0",
"arsd-official": "10.9.10",
"automem": "0.6.9",
"bindbc-freetype": "1.0.5",
"bindbc-loader": "1.0.3",
"bindbc-opengl": "1.0.5",
"bindbc-sdl": "1.0.1",
"botan": "1.13.6",
"botan-math": "1.0.4",
"cachetools": "0.4.1",
"concepts": "0.0.9",
"concurrency": "5.0.4",
"dfl": {"version":"224d9348286620c8ea4854690a09e7380d6f5b2f","repository":"git+https://github.com/Dadoum/dfl.git"},
"dlangui": "0.10.4",
"dqt": {"version":"6a44b55f3a3691da930cb9eefe2a745afe1b764d","repository":"git+https://github.com/tim-dlang/dqt.git"},
"dsfml": "2.1.1",
"dxml": "0.4.4",
"dynamic-loader": {"version":"65a8b8b8a6d44d47e63bddc985268592ecf47764","repository":"git+https://github.com/Dadoum/dynamicloader.git"},
"glx-d": "1.1.0",
"gtk_d": "1.0.3",
"icontheme": "1.2.3",
"ikod-containers": "0.0.22",
"inilike": "1.2.2",
"intel-intrinsics": "1.11.15",
"isfreedesktop": "0.1.1",
"keyring": {"path":"../../keyring/"},
"memutils": "1.0.10",
"mir-core": "1.6.0",
"plist": "~master",
"plist-d": {"version":"30d152e88767611e10048b25777ecb5f9075f87c","repository":"git+https://github.com/Dadoum/libplist-d.git"},
"progress": "5.0.2",
"provision": {"version":"533dca306b86f9c7801354b78f5187addb58b740","repository":"git+https://github.com/Dadoum/Provision.git"},
"requests": "2.1.2",
"sideloader": {"path":"../../"},
"silly": "1.2.0-dev.2",
"slf4d": "2.4.3",
"test_allocator": "0.3.4",
"undead": "1.1.8",
"unit-threaded": "0.10.8",
"windows-headers": "1.0.5",
"x11": "1.0.21",
"xdgpaths": "0.2.5"
}
}
2 changes: 1 addition & 1 deletion frontends/cli/source/app_id.d
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct AddAppId
@(PositionalArgument(0).Description("app name"))
string name;

@(PositionalArgument(0).Description("app identifier"))
@(PositionalArgument(1).Description("app identifier"))
string identifier;

int opCall()
Expand Down
4 changes: 3 additions & 1 deletion frontends/cli/source/cli_frontend.d
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ string defaultConfigurationPath()

import app_id;
import certificate;
import device;
import install;
// @(Command("login").Description("Log-in to your Apple account."))
// @(Command("logout").Description("Log-out."))
Expand Down Expand Up @@ -234,6 +235,7 @@ int entryPoint(Commands commands)
return commands.cmd.match!(
(AppIdCommand cmd) => cmd(),
(CertificateCommand cmd) => cmd(),
(DeviceCommand cmd) => cmd(),
(InstallCommand cmd) => cmd(),
(SignCommand cmd) => cmd(),
(TrollsignCommand cmd) => cmd(),
Expand All @@ -259,7 +261,7 @@ struct Commands
uint threadCount = uint.max;

@SubCommands
SumType!(AppIdCommand, CertificateCommand, InstallCommand, SignCommand, TrollsignCommand, TeamCommand, ToolCommand, VersionCommand) cmd;
SumType!(AppIdCommand, CertificateCommand, DeviceCommand, InstallCommand, SignCommand, TrollsignCommand, TeamCommand, ToolCommand, VersionCommand) cmd;
}

mixin CLI!Commands.main!entryPoint;
Expand Down
174 changes: 174 additions & 0 deletions frontends/cli/source/device.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
module device;

import std.algorithm;
import std.array;
import std.exception;
import std.stdio;
import std.sumtype;
import std.typecons;

import slf4d;
import slf4d.default_provider;

import botan.cert.x509.pkcs10;
import botan.filters.data_src;

import argparse;

import server.developersession;

import cli_frontend;

@(Command("device").Description("Manage registered devices."))
struct DeviceCommand
{
int opCall()
{
return cmd.match!(
(ListDevices cmd) => cmd(),
(AddDevice cmd) => cmd(),
(DeleteDevice cmd) => cmd()
);
}

@SubCommands
SumType!(ListDevices, AddDevice, DeleteDevice) cmd;
}

@(Command("list").Description("List registered devices."))
struct ListDevices
{
mixin LoginCommand;

@(NamedArgument("team").Description("Team ID"))
string teamId = null;

int opCall()
{
auto log = getLogger();

string configurationPath = systemConfigurationPath();

scope provisioningData = initializeADI(configurationPath);
scope adi = provisioningData.adi;
scope akDevice = provisioningData.device;

auto appleAccount = login(akDevice, adi);

if (!appleAccount) {
return 1;
}

auto teams = appleAccount.listTeams().unwrap();

string teamId = this.teamId;
if (teamId != null) {
teams = teams.filter!((elem) => elem.teamId == teamId).array();
}
enforce(teams.length > 0, "No matching team found.");

auto team = teams[0];

auto devices = appleAccount.listDevices!iOS(team).unwrap();

writefln!"You have %d devices registered."(devices.length);
writeln("Currently registered devices:");
foreach (device; devices) {
writefln!" - Device `%s` of UDID `%s` with the identifier `%s`"(device.name, device.deviceNumber, device.deviceId);
}

return 0;
}
}

@(Command("add").Description("Register device."))
struct AddDevice
{
mixin LoginCommand;

@(NamedArgument("team").Description("Team ID"))
string teamId = null;

@(PositionalArgument(0).Description("Device name"))
string name = void;

@(PositionalArgument(1).Description("Device UDID"))
string udid = void;

int opCall()
{
auto log = getLogger();

string configurationPath = systemConfigurationPath();

scope provisioningData = initializeADI(configurationPath);
scope adi = provisioningData.adi;
scope akDevice = provisioningData.device;

auto appleAccount = login(akDevice, adi);

if (!appleAccount) {
return 1;
}

auto teams = appleAccount.listTeams().unwrap();

string teamId = this.teamId;
if (teamId != null) {
teams = teams.filter!((elem) => elem.teamId == teamId).array();
}
enforce(teams.length > 0, "No matching team found.");

auto team = teams[0];

auto devices = appleAccount.addDevice!iOS(team, name, udid).unwrap();
log.info("Success!");

return 0;
}
}

@(Command("delete").Description("Unregister device."))
struct DeleteDevice
{
mixin LoginCommand;

@(NamedArgument("team").Description("Team ID"))
string teamId = null;

@(PositionalArgument(0).Description("Apple device's identifier (not UDID, check device list)."))
string deviceId = void;

int opCall()
{
auto log = getLogger();

string configurationPath = systemConfigurationPath();

scope provisioningData = initializeADI(configurationPath);
scope adi = provisioningData.adi;
scope akDevice = provisioningData.device;

auto appleAccount = login(akDevice, adi);

if (!appleAccount) {
return 1;
}

auto teams = appleAccount.listTeams().unwrap();

string teamId = this.teamId;
if (teamId != null) {
teams = teams.filter!((elem) => elem.teamId == teamId).array();
}
enforce(teams.length > 0, "No matching team found.");

auto team = teams[0];

auto devices = appleAccount.deleteDevice!iOS(team, deviceId).unwrap();
log.info("Success!");

return 0;
}
}

1 change: 0 additions & 1 deletion frontends/dlangui/dub.selections.json

This file was deleted.

47 changes: 47 additions & 0 deletions frontends/dlangui/dub.selections.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"fileVersion": 1,
"versions": {
"argparse": "1.3.0",
"arsd-official": "10.9.10",
"automem": "0.6.9",
"bindbc-freetype": "1.0.5",
"bindbc-loader": "1.0.3",
"bindbc-opengl": "1.0.5",
"bindbc-sdl": "1.0.1",
"botan": "1.13.6",
"botan-math": "1.0.4",
"cachetools": "0.4.1",
"concepts": "0.0.9",
"concurrency": "5.0.4",
"dfl": {"version":"224d9348286620c8ea4854690a09e7380d6f5b2f","repository":"git+https://github.com/Dadoum/dfl.git"},
"dlangui": "0.10.4",
"dqt": {"version":"6a44b55f3a3691da930cb9eefe2a745afe1b764d","repository":"git+https://github.com/tim-dlang/dqt.git"},
"dsfml": "2.1.1",
"dxml": "0.4.4",
"dynamic-loader": {"version":"65a8b8b8a6d44d47e63bddc985268592ecf47764","repository":"git+https://github.com/Dadoum/dynamicloader.git"},
"glx-d": "1.1.0",
"gtk_d": "1.0.3",
"icontheme": "1.2.3",
"ikod-containers": "0.0.22",
"inilike": "1.2.2",
"intel-intrinsics": "1.11.15",
"isfreedesktop": "0.1.1",
"keyring": {"path":"../../keyring/"},
"memutils": "1.0.10",
"mir-core": "1.6.0",
"plist": "~master",
"plist-d": {"version":"30d152e88767611e10048b25777ecb5f9075f87c","repository":"git+https://github.com/Dadoum/libplist-d.git"},
"progress": "5.0.2",
"provision": {"version":"533dca306b86f9c7801354b78f5187addb58b740","repository":"git+https://github.com/Dadoum/Provision.git"},
"requests": "2.1.2",
"sideloader": {"path":"../../"},
"silly": "1.2.0-dev.2",
"slf4d": "2.4.3",
"test_allocator": "0.3.4",
"undead": "1.1.8",
"unit-threaded": "0.10.8",
"windows-headers": "1.0.5",
"x11": "1.0.21",
"xdgpaths": "0.2.5"
}
}
1 change: 0 additions & 1 deletion frontends/gtk/dub.selections.json

This file was deleted.

47 changes: 47 additions & 0 deletions frontends/gtk/dub.selections.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"fileVersion": 1,
"versions": {
"argparse": "1.3.0",
"arsd-official": "10.9.10",
"automem": "0.6.9",
"bindbc-freetype": "1.0.5",
"bindbc-loader": "1.0.3",
"bindbc-opengl": "1.0.5",
"bindbc-sdl": "1.0.1",
"botan": "1.13.6",
"botan-math": "1.0.4",
"cachetools": "0.4.1",
"concepts": "0.0.9",
"concurrency": "5.0.4",
"dfl": {"version":"224d9348286620c8ea4854690a09e7380d6f5b2f","repository":"git+https://github.com/Dadoum/dfl.git"},
"dlangui": "0.10.4",
"dqt": {"version":"6a44b55f3a3691da930cb9eefe2a745afe1b764d","repository":"git+https://github.com/tim-dlang/dqt.git"},
"dsfml": "2.1.1",
"dxml": "0.4.4",
"dynamic-loader": {"version":"65a8b8b8a6d44d47e63bddc985268592ecf47764","repository":"git+https://github.com/Dadoum/dynamicloader.git"},
"glx-d": "1.1.0",
"gtk_d": "1.0.3",
"icontheme": "1.2.3",
"ikod-containers": "0.0.22",
"inilike": "1.2.2",
"intel-intrinsics": "1.11.15",
"isfreedesktop": "0.1.1",
"keyring": {"path":"../../keyring/"},
"memutils": "1.0.10",
"mir-core": "1.6.0",
"plist": "~master",
"plist-d": {"version":"30d152e88767611e10048b25777ecb5f9075f87c","repository":"git+https://github.com/Dadoum/libplist-d.git"},
"progress": "5.0.2",
"provision": {"version":"533dca306b86f9c7801354b78f5187addb58b740","repository":"git+https://github.com/Dadoum/Provision.git"},
"requests": "2.1.2",
"sideloader": {"path":"../../"},
"silly": "1.2.0-dev.2",
"slf4d": "2.4.3",
"test_allocator": "0.3.4",
"undead": "1.1.8",
"unit-threaded": "0.10.8",
"windows-headers": "1.0.5",
"x11": "1.0.21",
"xdgpaths": "0.2.5"
}
}
1 change: 0 additions & 1 deletion frontends/qt/dub.selections.json

This file was deleted.

Loading

0 comments on commit d484f73

Please sign in to comment.