manifest.pl 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use JSON::PP;
  5. @ARGV == 4 or
  6. die "usage: manifest.pl <name> <displayname> <description> <objective>";
  7. my ($name, $displayname, $description, $objective) = @ARGV;
  8. # This can be overridden by the build script.
  9. my $version = "Unidentified build";
  10. # Limits from
  11. # https://developer.kaiostech.com/docs/getting-started/main-concepts/manifest
  12. length($displayname) <= 20 or die "Name too long: $displayname";
  13. length($description) <= 40 or die "Subtitle too long: $description";
  14. $objective .= " Part of Simon Tatham's Portable Puzzle Collection.";
  15. # https://developer.kaiostech.com/docs/distribution/submission-guideline
  16. length($objective) <= 220 or die "Description too long: $objective";
  17. my $decvers;
  18. if ($version =~ /^20(\d\d)(\d\d)(\d\d)\./) {
  19. # Fabricate a dotted-decimal version number as required by KaiOS.
  20. # The precise requirements are unclear and violating them leads to
  21. # messes in the KaiStore that can only be resolved by Developer
  22. # Support. Specifically, uploading a bad version number as the
  23. # first upload of an app can make it impossible to upload a new
  24. # version. I hope that three components of two digits each seem
  25. # to be acceptable.
  26. $decvers = join('.', $1+0, $2+0, $3+0);
  27. }
  28. print JSON::PP->new->canonical->encode({
  29. name => $displayname,
  30. subtitle => $description,
  31. description => $objective,
  32. launch_path => "/${name}.html",
  33. icons => {
  34. "56" => "/${name}-56kai.png",
  35. "112" => "/${name}-112kai.png",
  36. },
  37. developer => {
  38. name => "Ben Harris",
  39. url => "https://bjh21.me.uk",
  40. },
  41. default_locale => "en-GB",
  42. locales => {
  43. "en-GB" => {
  44. name => $displayname,
  45. subtitle => $description,
  46. description => $objective,
  47. },
  48. },
  49. categories => ["games"],
  50. type => "web",
  51. cursor => JSON::PP::false,
  52. # These permissions could be removed on builds without KaiAds,
  53. # but that's a bit complicated.
  54. permissions => {
  55. mobiledata => {
  56. description => "Required to display advertisements"
  57. },
  58. wifidata => {
  59. description => "Required to display advertisements"
  60. },
  61. },
  62. csp => "default-src 'self';
  63. script-src 'self' https://*.kaiads.com;
  64. style-src 'self' 'unsafe-inline';
  65. frame-src 'self' https://*.kaiads.com;
  66. img-src 'self' data:;" =~ s/\s+/ /gr,
  67. $decvers ? (version => $decvers) : (),
  68. })