Skip to content

Commit

Permalink
implement and enforce ubports_no-unused-user_actions keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoTheThird committed Mar 21, 2022
1 parent e3b0b31 commit c1477d2
Show file tree
Hide file tree
Showing 23 changed files with 35 additions and 120 deletions.
32 changes: 32 additions & 0 deletions v2/ajv-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,38 @@ module.exports = function (ajv) {
}
});

// ensure a user_action is used somewhere
ajv.addKeyword({
keyword: "ubports_no-unused-user_actions",
type: "object",
compile:
() =>
(_, { rootData, parentDataProperty: action }) =>
rootData?.unlock?.indexOf(action) !== -1 ||
rootData?.operating_systems?.reduce(
(prev, { prerequisites, steps }) =>
prev ||
prerequisites?.indexOf(action) !== -1 ||
steps
.map(({ actions, fallback }) => [
...(actions || []),
...(fallback || [])
])
.flat()
.filter(a => {
if (a["core:group"])
throw new Error(
"core:group desctructuring not yet implemented"
);
else return a["core:user_action"]?.action === action;
}).length,
false
),
error: {
message: "no unused user_actions"
}
});

// ensure a semver string is a valid reference
ajv.addKeyword({
keyword: "ubports_semver",
Expand Down
5 changes: 0 additions & 5 deletions v2/devices/X00TD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ user_actions:
description: "With the device powered off, hold Volume Down + Power."
image: "phone_power_down"
button: true
boot:
title: "Boot the device"
description: "Power on the device."
image: "phone_power_up"
button: true
confirm_model:
title: "Confirm your model"
description: "Please double-check that your device is a Asus Zenfone Max Pro M1 (X00TD)."
Expand Down
5 changes: 0 additions & 5 deletions v2/devices/begonia.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ formfactor: "phone"
aliases: []
doppelgangers: []
user_actions:
recovery:
title: "Reboot to Recovery"
description: "With the device powered off, hold Volume Up + Power."
image: "phone_power_up"
button: true
bootloader:
title: "Reboot to Bootloader"
description: "With the device powered off, hold Volume Down + Power."
Expand Down
5 changes: 0 additions & 5 deletions v2/devices/beryllium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ user_actions:
description: "With the device powered off, hold Volume Up + Power."
image: "phone_power_up"
button: true
boot:
title: "Boot the device"
description: "Power on the device."
image: "phone_power_up"
button: true
confirm_model:
title: "Confirm your model"
description: "Please double-check that your device is a Xiaomi Poco F1 (beryllium)."
Expand Down
12 changes: 0 additions & 12 deletions v2/devices/cheeseburger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ user_actions:
description: "With the device powered off, press and hold the volume up and power buttons until the screen turns on. It should say 'Fastboot Mode' underneath the warning sign."
image: "phone_power_up"
button: true
reboot:
title: "Reboot the device"
description: "Hold down the power button until the device powers down. Then, release it briefly and hold it down again until the device boots."
button: true
twrp_unlock:
title: "TWRP unlock"
description: 'Your device will boot Team Win Recovery Project (TWRP). If the screen is off, hit the power button once to light it up, then swipe the bar in the bottom to the right where it says to "Swipe to allow modifications."'
Expand All @@ -36,14 +32,6 @@ user_actions:
title: "TWRP sideload"
description: 'Select "Advanced" and then "ADB Sideload". Check the boxes "Wipe Dalvik Cache" and "Wipe Cache" and then swipe the bar in the bottom where it says "Swipe to Start Sideload".'
button: true
twrp_sideload_reboot:
title: "Sideload complete!"
description: "Follow the on-screen instructions to complete the sideload."
button: true
untested:
title: "Untested"
description: "Sorry, this configuration has not yet been fully tested. You might run into issues. If you want to help us improve, click the link below to see the config file."
button: true
unlock:
- "update"
- "twrp"
Expand Down
5 changes: 0 additions & 5 deletions v2/devices/dipper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ user_actions:
description: "With the device powered off, hold Volume Up + Power."
image: "phone_power_up"
button: true
boot:
title: "Boot the device"
description: "Power on the device."
image: "phone_power_up"
button: true
confirm_model:
title: "Confirm your model"
description: "Please double-check that your device is a Xiaomi Mi 8 (dipper)."
Expand Down
12 changes: 0 additions & 12 deletions v2/devices/dumpling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ user_actions:
description: "With the device powered off, hold Volume Up + Power."
image: "phone_power_up"
button: true
reboot:
title: "Reboot the device"
description: "Hold down the power button until the device powers down. Then, release it briefly and hold it down again until the device boots."
button: true
twrp_unlock:
title: "TWRP unlock"
description: 'Your device will boot Team Win Recovery Project (TWRP). If the screen is off, hit the power button once to light it up, then swipe the bar in the bottom to the right where it says to "Swipe to allow modifications."'
Expand All @@ -36,14 +32,6 @@ user_actions:
title: "TWRP sideload"
description: 'Select "Advanced" and then "ADB Sideload". Check the boxes "Wipe Dalvik Cache" and "Wipe Cache" and then swipe the bar in the bottom where it says "Swipe to Start Sideload".'
button: true
twrp_sideload_reboot:
title: "Sideload complete!"
description: "Follow the on-screen instructions to complete the sideload."
button: true
untested:
title: "Untested"
description: "Sorry, this configuration has not yet been fully tested. You might run into issues. If you want to help us improve, click the link below to see the config file."
button: true
unlock:
- "update"
- "twrp"
Expand Down
5 changes: 0 additions & 5 deletions v2/devices/land.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ user_actions:
description: "With the device powered off, hold Volume Down + Power"
image: "phone_power_down"
button: true
boot:
title: "Boot the device"
description: "Power on the device."
image: "phone_power_up"
button: true
unlock:
title: "OEM unlock"
description: "If you haven't done so already, make sure to OEM unlock your device first."
Expand Down
5 changes: 0 additions & 5 deletions v2/devices/miatoll.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ user_actions:
description: "With the device powered off, hold Volume Down + Power."
image: "phone_power_down"
button: true
boot:
title: "Boot the device"
description: "Power on the device."
image: "phone_power_up"
button: true
confirm_model:
title: "Confirm your model"
description: "Please double-check that your device is any of the following models: Xiaomi Redmi Note 9 Pro/Pro Max/9S - Poco M2 Pro (joyeuse, excalibur, curtana, gram)."
Expand Down
5 changes: 0 additions & 5 deletions v2/devices/onclite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ user_actions:
description: "With the device powered off, hold Volume Down + Power."
image: "phone_power_down"
button: true
boot:
title: "Boot the device"
description: "Power on the device."
image: "phone_power_up"
button: true
confirm_model:
title: "Confirm your model"
description: "Please double-check that your device is a Xiaomi Redmi 7 (onc/onclite)."
Expand Down
4 changes: 0 additions & 4 deletions v2/devices/oneplus2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ user_actions:
title: "Sideload complete!"
description: "Follow the on-screen instructions to complete the sideload."
button: true
untested:
title: "Untested"
description: "Sorry, this configuration has not yet been fully tested. You might run into issues. If you want to help us improve, click the link below to see the config file."
button: true
unlock:
- "update"
- "twrp"
Expand Down
5 changes: 0 additions & 5 deletions v2/devices/perseus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ user_actions:
description: "With the device powered off, hold Volume Down + Power."
image: "phone_power_down"
button: true
boot:
title: "Boot the device"
description: "Power on the device."
image: "phone_power_up"
button: true
confirm_model:
title: "Confirm your model"
description: "Please double-check that your device is a Xiaomi Mi MIX 3 (perseus)."
Expand Down
4 changes: 0 additions & 4 deletions v2/devices/s3ve3g.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ user_actions:
description: 'With the device powered off, hold Volume Down + Power. You might be prompted to select a mode to boot into. If that happens, follow the on-screen instructions and select "Download" mode.'
image: "phone_power_down"
button: true
confirm_download:
title: "Confirm Download Mode"
description: "Wait until the phone has entered download mode. You should see a green robot and a warning."
button: true
confirm_replug:
title: "Unplug and Replug"
description: "Wait until the phone has rebooted and shows a small red text. Unplug and replug once the USB cable"
Expand Down
5 changes: 0 additions & 5 deletions v2/devices/sagit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ user_actions:
description: "With the device powered off, hold Volume Down + Power."
image: "phone_power_down"
button: true
boot:
title: "Boot the device"
description: "Power on the device."
image: "phone_power_up"
button: true
confirm_model:
title: "Confirm your model"
description: "Please double-check that your device is a Xiaomi Mi 6 (sagit)."
Expand Down
5 changes: 0 additions & 5 deletions v2/devices/santoni.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ user_actions:
description: "With the device powered off, hold Volume Down + Power"
image: "phone_power_down"
button: true
boot:
title: "Boot the device"
description: "Power on the device."
image: "phone_power_up"
button: true
unlock:
title: "OEM unlock"
description: "If you haven't done so already, make sure to OEM unlock your device first."
Expand Down
4 changes: 0 additions & 4 deletions v2/devices/trlte.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ user_actions:
description: "If your device did not reboot to Download Mode, then press, and hold Volume Down + Home + Power, until you see the Warning about Custom OS installations, press Volume Up to Continue, then you may have to unplug and plug the USB cord back in."
image: "phone_power_down"
button: true
boot:
title: "Reboot the device"
description: "Hold down the Volume Down + Home + Power button until the device vibrates, then release all buttons."
button: true
trlte_check:
title: "Unlock Bootloader"
description: "You need to ensure you have an unlocked bootloader, which can be tested by installing TWRP. The Verizon variant should be the only variant with a locked bootloader, click 'More...' for instructions to unlock your Verizon Note 4, there is currently no solution for unlocking the AT&T variant, Sorry. :("
Expand Down
4 changes: 0 additions & 4 deletions v2/devices/trltespr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ user_actions:
description: "If your device did not reboot to Download Mode, then press, and hold Volume Down + Home + Power, until you see the Warning about Custom OS installations, press Volume Up to Continue, then you may have to unplug and plug the USB cord back in."
image: "phone_power_down"
button: true
boot:
title: "Reboot the device"
description: "Hold down the Volume Down + Home + Power button until the device vibrates, then release all buttons."
button: true
trlte_check:
title: "Unlock Bootloader"
description: "You need to ensure you have an unlocked bootloader, which can be tested by installing TWRP. The Verizon variant should be the only variant with a locked bootloader, click 'More...' for instructions to unlock your Verizon Note 4, there is currently no solution for unlocking the AT&T variant, Sorry. :("
Expand Down
4 changes: 0 additions & 4 deletions v2/devices/trltetmo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ user_actions:
description: "If your device did not reboot to Download Mode, then press, and hold Volume Down + Home + Power, until you see the Warning about Custom OS installations, press Volume Up to Continue, then you may have to unplug and plug the USB cord back in."
image: "phone_power_down"
button: true
boot:
title: "Reboot the device"
description: "Hold down the Volume Down + Home + Power button until the device vibrates, then release all buttons."
button: true
trlte_check:
title: "Unlock Bootloader"
description: "You need to ensure you have an unlocked bootloader, which can be tested by installing TWRP. The Verizon variant should be the only variant with a locked bootloader, click 'More...' for instructions to unlock your Verizon Note 4, there is currently no solution for unlocking the AT&T variant, Sorry. :("
Expand Down
5 changes: 0 additions & 5 deletions v2/devices/violet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ user_actions:
description: "With the device powered off, hold Volume Down + Power."
image: "phone_power_down"
button: true
boot:
title: "Boot the device"
description: "Power on the device."
image: "phone_power_up"
button: true
confirm_model:
title: "Confirm your model"
description: "Please double-check that your device is a Xiaomi Redmi Note 7 Pro (violet)."
Expand Down
1 change: 1 addition & 0 deletions v2/devices/yggdrasil.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ operating_systems:
link: "https://volla.online/en/eula/index.html"
- name: "SailfishOS"
compatible_installer: ">=0.9.2-beta"
prerequisites: []
options:
- var: "bootstrap"
name: "Bootstrap"
Expand Down
21 changes: 0 additions & 21 deletions v2/devices/yggdrasilx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,6 @@ user_actions:
title: "Reboot the device"
description: "Hold down the power button until the device powers down. Then, release it briefly and hold it down again until the device boots."
button: true
twrp_unlock:
title: "TWRP unlock"
description: 'Your device will boot Team Win Recovery Project (TWRP). If the screen is off, hit the power button once to light it up, then swipe the bar in the bottom to the right where it says to "Swipe to allow modifications."'
button: true
twrp_sideload:
title: "TWRP sideload"
description: 'Select "Advanced" and then "ADB Sideload". Check the boxes "Wipe Dalvik Cache" and "Wipe Cache" and then swipe the bar in the bottom where it says "Swipe to Start Sideload".'
button: true
twrp_sideload_again:
title: "TWRP sideload"
description: 'Select "Back" and then select "ADB Sideload" again. Ensure the boxes "Wipe Dalvik Cache" and "Wipe Cache" are checked and then swipe the bar in the bottom where it says "Swipe to Start Sideload".'
button: true
twrp_sideload_reboot:
title: "Sideload complete!"
description: "Follow the on-screen instructions to complete the sideload. Your device will reboot to the new OS next."
button: true
untested:
title: "Untested"
description: "Sorry, this configuration has not yet been fully tested. You might run into issues. If you want to help us improve, click the link below to see the config file."
link: "https://github.com/ubports/installer-configs/blob/master/v1/yggdrasil.json"
button: true
unlock: []
handlers:
bootloader_locked:
Expand Down
1 change: 1 addition & 0 deletions v2/schema/operating_systems.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ items:
required:
- "name"
- "compatible_installer"
- "prerequisites"
- "steps"
properties:
name:
Expand Down
1 change: 1 addition & 0 deletions v2/schema/user_actions.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ patternProperties:
title: "User action"
type: "object"
description: "Instruction that can be referenced and presented to the user. Eg key combinations to reboot to recovery or bootloader."
ubports_no-unused-user_actions:
properties:
title:
title: Title
Expand Down

0 comments on commit c1477d2

Please sign in to comment.