Merge branch 'validate'
This commit is contained in:
commit
fb940c9ae8
|
@ -1,8 +1,6 @@
|
||||||
require 'json'
|
require_relative 'osia_helper'
|
||||||
|
|
||||||
c = File.read 'contents.json'
|
|
||||||
j = JSON.parse c
|
|
||||||
|
|
||||||
|
j = get_json
|
||||||
c = j['categories']
|
c = j['categories']
|
||||||
|
|
||||||
c.sort_by { |h| h['title']}
|
c.sort_by { |h| h['title']}
|
|
@ -1,45 +1,11 @@
|
||||||
|
require_relative 'osia_helper'
|
||||||
require 'date'
|
require 'date'
|
||||||
require 'json'
|
|
||||||
|
|
||||||
README = 'README.md'
|
README = 'README.md'
|
||||||
|
|
||||||
ARCHIVE = 'ARCHIVE.md'
|
ARCHIVE = 'ARCHIVE.md'
|
||||||
ARCHIVE_TAG = 'archive'
|
ARCHIVE_TAG = 'archive'
|
||||||
|
|
||||||
def output_stars(number)
|
|
||||||
case number
|
|
||||||
when 100...200
|
|
||||||
'🔥'
|
|
||||||
when 200...500
|
|
||||||
'🔥🔥'
|
|
||||||
when 500...1000
|
|
||||||
'🔥🔥🔥'
|
|
||||||
when 1000...2000
|
|
||||||
'🔥🔥🔥🔥'
|
|
||||||
when 2000...100000
|
|
||||||
'🔥🔥🔥🔥🔥'
|
|
||||||
else
|
|
||||||
''
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def output_flag(lang)
|
|
||||||
case lang
|
|
||||||
when 'jpn'
|
|
||||||
'🇯🇵'
|
|
||||||
when 'ltz'
|
|
||||||
'🇱🇺'
|
|
||||||
when 'por'
|
|
||||||
'🇧🇷'
|
|
||||||
when 'spa'
|
|
||||||
'🇪🇸'
|
|
||||||
when 'zho'
|
|
||||||
'🇨🇳'
|
|
||||||
else
|
|
||||||
''
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def apps_archived(apps)
|
def apps_archived(apps)
|
||||||
a = apps.select {|a| a['tags'] != nil }.select {|b| b['tags'].include?ARCHIVE_TAG}
|
a = apps.select {|a| a['tags'] != nil }.select {|b| b['tags'].include?ARCHIVE_TAG}
|
||||||
a.sort_by { |k, v| k['title'] }
|
a.sort_by { |k, v| k['title'] }
|
||||||
|
@ -103,6 +69,40 @@ def output_apps(apps)
|
||||||
o
|
o
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def output_flag(lang)
|
||||||
|
case lang
|
||||||
|
when 'jpn'
|
||||||
|
'🇯🇵'
|
||||||
|
when 'ltz'
|
||||||
|
'🇱🇺'
|
||||||
|
when 'por'
|
||||||
|
'🇧🇷'
|
||||||
|
when 'spa'
|
||||||
|
'🇪🇸'
|
||||||
|
when 'zho'
|
||||||
|
'🇨🇳'
|
||||||
|
else
|
||||||
|
''
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def output_stars(number)
|
||||||
|
case number
|
||||||
|
when 100...200
|
||||||
|
'🔥'
|
||||||
|
when 200...500
|
||||||
|
'🔥🔥'
|
||||||
|
when 500...1000
|
||||||
|
'🔥🔥🔥'
|
||||||
|
when 1000...2000
|
||||||
|
'🔥🔥🔥🔥'
|
||||||
|
when 2000...100000
|
||||||
|
'🔥🔥🔥🔥🔥'
|
||||||
|
else
|
||||||
|
''
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def write_readme(j)
|
def write_readme(j)
|
||||||
t = j['title']
|
t = j['title']
|
||||||
desc = j['description']
|
desc = j['description']
|
||||||
|
@ -178,8 +178,7 @@ def write_archive(j)
|
||||||
puts "wrote #{file} ✨"
|
puts "wrote #{file} ✨"
|
||||||
end
|
end
|
||||||
|
|
||||||
c = File.read 'contents.json'
|
j = get_json
|
||||||
j = JSON.parse c
|
|
||||||
|
|
||||||
write_readme(j)
|
write_readme(j)
|
||||||
write_archive(j)
|
write_archive(j)
|
|
@ -0,0 +1,7 @@
|
||||||
|
require 'json'
|
||||||
|
|
||||||
|
FILE = 'contents.json'
|
||||||
|
|
||||||
|
def get_json
|
||||||
|
JSON.parse(File.read FILE)
|
||||||
|
end
|
|
@ -1,15 +1,11 @@
|
||||||
require 'json'
|
require_relative 'osia_helper'
|
||||||
|
|
||||||
require 'octokit'
|
require 'octokit'
|
||||||
require 'netrc'
|
require 'netrc'
|
||||||
|
|
||||||
FILE = 'contents.json'
|
|
||||||
|
|
||||||
c = File.read FILE
|
|
||||||
j = JSON.parse c
|
|
||||||
|
|
||||||
client = Octokit::Client.new(:netrc => true)
|
client = Octokit::Client.new(:netrc => true)
|
||||||
|
|
||||||
|
j = get_json
|
||||||
apps = j['projects']
|
apps = j['projects']
|
||||||
updated = []
|
updated = []
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
require_relative 'osia_helper'
|
||||||
|
|
||||||
|
j = get_json
|
||||||
|
c = j['categories']
|
||||||
|
a = j['projects']
|
||||||
|
|
||||||
|
def failed(cat, app)
|
||||||
|
puts "‼️ #{cat} is not a valid category for #{app}"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def verify(cat, allowed, app)
|
||||||
|
failed(cat, app) unless allowed.include? cat
|
||||||
|
end
|
||||||
|
|
||||||
|
allowed_categories = c.sort_by { |h| h['title']}.map { |x| x['id']}
|
||||||
|
|
||||||
|
a.each do |a|
|
||||||
|
cat = a['category']
|
||||||
|
|
||||||
|
if cat.nil?
|
||||||
|
# failed(cat, a)
|
||||||
|
puts "missing category for #{a}"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if cat.class == String
|
||||||
|
verify(cat, allowed_categories, a)
|
||||||
|
elsif cat.class == Array
|
||||||
|
cat.each { |c| verify(c, allowed_categories, a) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
puts 'categories validated ✅'
|
|
@ -8,6 +8,7 @@ test:
|
||||||
override:
|
override:
|
||||||
- awesome_bot contents.json --white-list developer.apple
|
- awesome_bot contents.json --white-list developer.apple
|
||||||
- json validate --schema-file=.github/schema.json --document-file=contents.json
|
- json validate --schema-file=.github/schema.json --document-file=contents.json
|
||||||
|
- ruby .github/osia_validate_categories.rb
|
||||||
general:
|
general:
|
||||||
artifacts:
|
artifacts:
|
||||||
- "ab-results.json"
|
- "ab-results.json"
|
||||||
|
@ -15,5 +16,5 @@ deployment:
|
||||||
master:
|
master:
|
||||||
branch: master
|
branch: master
|
||||||
commands:
|
commands:
|
||||||
- ruby .github/convert.rb
|
- ruby .github/osia_convert.rb
|
||||||
- ./.github/deploy.sh
|
- ./.github/deploy.sh
|
||||||
|
|
Loading…
Reference in New Issue